0

My Laravel 6.0 app was working fine on Google App Engine until I included database integration with Cloud SQL.

I made some changes to the app.yaml file, set up the 2nd gen MySQL instance and deployed the same app. However, I am now faced with a 500 Internal Server Error. The logs did not explain what happened. What am I missing here?

Here's the final app.yaml file used to deploy the app.

#app.yaml

runtime: php
env: flex

runtime_config:
  document_root: public

env_variables:
  # Put production environment variables here.
  APP_LOG: errorlog
  APP_KEY: base64:HRJlC5LuMqjl7p98Lb2udzV6jKOnGFohu8dG3COBtmc=
  APP_STORAGE: /tmp
  VIEW_COMPILED_PATH: /tmp
  CACHE_DRIVER: database
  SESSION_DRIVER: database
  ## Set these environment variables according to your CloudSQL configuration.
  DB_DATABASE: cbt-sql
  DB_USERNAME: root
  DB_PASSWORD: secret
  DB_SOCKET: "/cloudsql/theta-byte-123456:asia-southeast1:cbt-sql"

The below logs are for the instance deployed to GAE.

#gcloud Logs Viewer

A 2019-09-29T08:58:36Z 2019-09-29 08:58:36,646 CRIT Supervisor running as root (no user in config file)

A 2019-09-29T08:58:36Z 2019-09-29 08:58:36,653 WARN No file matches via include "/etc/supervisor/conf.d/*.conf"

A 2019-09-29T08:58:36Z 2019-09-29 08:58:36,668 INFO supervisord started with pid 1

A 2019-09-29T08:58:37Z 2019-09-29 08:58:37,678 INFO spawned: 'php-fpm' with pid 8

A 2019-09-29T08:58:37Z 2019-09-29 08:58:37,688 INFO spawned: 'nginx' with pid 9

A 2019-09-29T08:58:38Z 2019-09-29 08:58:38,302 CRIT Supervisor running as root (no user in config file)

A 2019-09-29T08:58:38Z 2019-09-29 08:58:38,303 WARN No file matches via include "/etc/supervisor/conf.d/*.conf"

A 2019-09-29T08:58:38Z 2019-09-29 08:58:38,340 INFO supervisord started with pid 1

A 2019-09-29T08:58:38Z 2019/09/29 08:58:37 [notice] 9#9: using the "epoll" event method

A 2019-09-29T08:58:38Z 2019/09/29 08:58:37 [notice] 9#9: nginx/1.10.3 (Ubuntu)

A 2019-09-29T08:58:38Z 2019/09/29 08:58:37 [notice] 9#9: OS: Linux 4.14.137+

A 2019-09-29T08:58:38Z 2019/09/29 08:58:37 [notice] 9#9: getrlimit(RLIMIT_NOFILE): 1048576:1048576

A 2019-09-29T08:58:38Z 2019/09/29 08:58:37 [notice] 9#9: start worker processes

A 2019-09-29T08:58:38Z 2019/09/29 08:58:37 [notice] 9#9: start worker process 10

A 2019-09-29T08:58:38Z [29-Sep-2019 08:58:38] NOTICE: fpm is running, pid 8

A 2019-09-29T08:58:38Z [29-Sep-2019 08:58:38] NOTICE: ready to handle connections

A 2019-09-29T08:58:39Z 2019-09-29 08:58:39,343 INFO spawned: 'php-fpm' with pid 8

A 2019-09-29T08:58:39Z 2019-09-29 08:58:39,346 INFO spawned: 'nginx' with pid 9

A 2019-09-29T08:58:39Z 2019-09-29 08:58:39,156 INFO success: php-fpm entered RUNNING state, process has stayed up for > than 1 seconds (startsecs)

A 2019-09-29T08:58:39Z 2019-09-29 08:58:39,157 INFO success: nginx entered RUNNING state, process has stayed up for > than 1 seconds (startsecs)

A 2019-09-29T08:58:40Z 2019/09/29 08:58:39 [notice] 9#9: using the "epoll" event method

A 2019-09-29T08:58:40Z 2019/09/29 08:58:39 [notice] 9#9: nginx/1.10.3 (Ubuntu)

A 2019-09-29T08:58:40Z 2019/09/29 08:58:39 [notice] 9#9: OS: Linux 4.14.137+

A 2019-09-29T08:58:40Z 2019/09/29 08:58:39 [notice] 9#9: getrlimit(RLIMIT_NOFILE): 1048576:1048576

A 2019-09-29T08:58:40Z 2019/09/29 08:58:39 [notice] 9#9: start worker processes

A 2019-09-29T08:58:40Z 2019/09/29 08:58:39 [notice] 9#9: start worker process 10

A 2019-09-29T08:58:40Z 2019-09-29 08:58:40,361 INFO success: php-fpm entered RUNNING state, process has stayed up for > than 1 seconds (startsecs)

A 2019-09-29T08:58:40Z 2019-09-29 08:58:40,362 INFO success: nginx entered RUNNING state, process has stayed up for > than 1 seconds (startsecs)

A 2019-09-29T08:58:40Z [29-Sep-2019 08:58:40] NOTICE: fpm is running, pid 8

A 2019-09-29T08:58:40Z [29-Sep-2019 08:58:40] NOTICE: ready to handle connections

A 2019-09-29T09:00:25Z 2019-09-29 09:00:25,054 CRIT Supervisor running as root (no user in config file)

A 2019-09-29T09:00:25Z 2019-09-29 09:00:25,056 WARN No file matches via include "/etc/supervisor/conf.d/*.conf"

A 2019-09-29T09:00:25Z 2019-09-29 09:00:25,082 INFO supervisord started with pid 1

A 2019-09-29T09:00:26Z 2019-09-29 09:00:26,088 INFO spawned: 'php-fpm' with pid 8

A 2019-09-29T09:00:26Z 2019-09-29 09:00:26,094 INFO spawned: 'nginx' with pid 9

A 2019-09-29T09:00:26Z 2019/09/29 09:00:26 [notice] 9#9: using the "epoll" event method

A 2019-09-29T09:00:26Z 2019/09/29 09:00:26 [notice] 9#9: nginx/1.10.3 (Ubuntu)

A 2019-09-29T09:00:26Z 2019/09/29 09:00:26 [notice] 9#9: OS: Linux 4.14.137+

A 2019-09-29T09:00:26Z 2019/09/29 09:00:26 [notice] 9#9: getrlimit(RLIMIT_NOFILE): 1048576:1048576

A 2019-09-29T09:00:26Z 2019/09/29 09:00:26 [notice] 9#9: start worker processes

A 2019-09-29T09:00:26Z 2019/09/29 09:00:26 [notice] 9#9: start worker process 10

A 2019-09-29T09:00:26Z [29-Sep-2019 09:00:26] NOTICE: fpm is running, pid 8

A 2019-09-29T09:00:26Z [29-Sep-2019 09:00:26] NOTICE: ready to handle connections

A 2019-09-29T09:00:27Z 2019-09-29 09:00:27,419 INFO success: php-fpm entered RUNNING state, process has stayed up for > than 1 seconds (startsecs)

A 2019-09-29T09:00:27Z 2019-09-29 09:00:27,419 INFO success: nginx entered RUNNING state, process has stayed up for > than 1 seconds (startsecs)

A 2019-09-29T09:00:36Z 2019-09-29 09:00:36,718 CRIT Supervisor running as root (no user in config file)

A 2019-09-29T09:00:36Z 2019-09-29 09:00:36,718 WARN No file matches via include "/etc/supervisor/conf.d/*.conf"

A 2019-09-29T09:00:36Z 2019-09-29 09:00:36,728 INFO supervisord started with pid 1

A 2019-09-29T09:00:37Z 2019-09-29 09:00:37,730 INFO spawned: 'php-fpm' with pid 8

A 2019-09-29T09:00:37Z 2019-09-29 09:00:37,734 INFO spawned: 'nginx' with pid 9

A 2019-09-29T09:00:37Z 2019/09/29 09:00:37 [notice] 9#9: using the "epoll" event method

A 2019-09-29T09:00:37Z 2019/09/29 09:00:37 [notice] 9#9: nginx/1.10.3 (Ubuntu)

A 2019-09-29T09:00:37Z 2019/09/29 09:00:37 [notice] 9#9: OS: Linux 4.14.137+

A 2019-09-29T09:00:37Z 2019/09/29 09:00:37 [notice] 9#9: getrlimit(RLIMIT_NOFILE): 1048576:1048576

A 2019-09-29T09:00:37Z 2019/09/29 09:00:37 [notice] 9#9: start worker processes

A 2019-09-29T09:00:37Z 2019/09/29 09:00:37 [notice] 9#9: start worker process 10

A 2019-09-29T09:00:38Z [29-Sep-2019 09:00:38] NOTICE: fpm is running, pid 8

A 2019-09-29T09:00:38Z [29-Sep-2019 09:00:38] NOTICE: ready to handle connections

A 2019-09-29T09:00:39Z 2019-09-29 09:00:39,076 INFO success: php-fpm entered RUNNING state, process has stayed up for > than 1 seconds (startsecs)

A 2019-09-29T09:00:39Z 2019-09-29 09:00:39,076 INFO success: nginx entered RUNNING state, process has stayed up for > than 1 seconds (startsecs)

A 2019-09-29T09:12:00Z 2019-09-29 09:11:59,763 WARN received SIGTERM indicating exit request

A 2019-09-29T09:12:00Z 2019-09-29 09:12:00,056 INFO waiting for nginx, php-fpm to die

A 2019-09-29T09:12:00Z 2019/09/29 09:12:00 [notice] 9#9: signal 15 (SIGTERM) received, exiting

A 2019-09-29T09:12:00Z 2019/09/29 09:12:00 [notice] 10#10: exiting

A 2019-09-29T09:12:00Z 2019/09/29 09:12:00 [notice] 9#9: signal 14 (SIGALRM) received

A 2019-09-29T09:12:00Z 2019/09/29 09:12:00 [notice] 9#9: signal 14 (SIGALRM) received

A 2019-09-29T09:12:00Z 2019/09/29 09:12:00 [notice] 9#9: signal 14 (SIGALRM) received

A 2019-09-29T09:12:00Z 2019/09/29 09:12:00 [notice] 10#10: exit

A 2019-09-29T09:12:00Z 2019/09/29 09:12:00 [notice] 9#9: signal 14 (SIGALRM) received

A 2019-09-29T09:12:00Z 2019/09/29 09:12:00 [notice] 9#9: signal 17 (SIGCHLD) received

A 2019-09-29T09:12:00Z 2019/09/29 09:12:00 [notice] 9#9: worker process 10 exited with code 0

A 2019-09-29T09:12:01Z 2019/09/29 09:12:00 [notice] 9#9: exit

A 2019-09-29T09:12:01Z 2019-09-29 09:12:01,152 INFO stopped: nginx (exit status 0)

A 2019-09-29T09:12:01Z [29-Sep-2019 09:12:01] NOTICE: Terminating ...

A 2019-09-29T09:12:01Z [29-Sep-2019 09:12:01] NOTICE: exiting, bye-bye!

A 2019-09-29T09:12:01Z 2019-09-29 09:12:01,739 INFO stopped: php-fpm (exit status 0)

A 2019-09-29T09:13:18Z 2019-09-29 09:13:18,511 WARN received SIGTERM indicating exit request

A 2019-09-29T09:13:18Z 2019-09-29 09:13:18,770 INFO waiting for nginx, php-fpm to die

A 2019-09-29T09:13:18Z 2019/09/29 09:13:18 [notice] 9#9: signal 15 (SIGTERM) received, exiting

A 2019-09-29T09:13:18Z 2019/09/29 09:13:18 [notice] 10#10: exiting

A 2019-09-29T09:13:18Z 2019/09/29 09:13:18 [notice] 9#9: signal 14 (SIGALRM) received

A 2019-09-29T09:13:18Z 2019/09/29 09:13:18 [notice] 9#9: signal 14 (SIGALRM) received

A 2019-09-29T09:13:19Z 2019/09/29 09:13:18 [notice] 10#10: exit

A 2019-09-29T09:13:19Z 2019/09/29 09:13:19 [notice] 9#9: signal 14 (SIGALRM) received

A 2019-09-29T09:13:19Z 2019/09/29 09:13:19 [notice] 9#9: signal 14 (SIGALRM) received

A 2019-09-29T09:13:19Z 2019/09/29 09:13:19 [notice] 9#9: signal 17 (SIGCHLD) received

A 2019-09-29T09:13:19Z 2019/09/29 09:13:19 [notice] 9#9: worker process 10 exited with code 0

A 2019-09-29T09:13:19Z 2019/09/29 09:13:19 [notice] 9#9: exit

A 2019-09-29T09:13:19Z 2019-09-29 09:13:19,738 INFO stopped: nginx (exit status 0)

A 2019-09-29T09:13:19Z [29-Sep-2019 09:13:19] NOTICE: Terminating ...

A 2019-09-29T09:13:19Z [29-Sep-2019 09:13:19] NOTICE: exiting, bye-bye!

A 2019-09-29T09:13:20Z 2019-09-29 09:13:20,565 INFO stopped: php-fpm (exit status 0)

A 2019-09-29T09:42:28Z 172.17.0.5 - - [29/Sep/2019:09:42:28 +0000] "GET / HTTP/1.1" 500 1570 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/77.0.3865.90 Safari/537.36"

A 2019-09-29T09:42:28.759Z GET 500 1.53 KiB 2.8 s Chrome 77 / GET 500 1.53 KiB 2.8 s Chrome 77 
A 2019-09-29T09:42:29.002621440Z GET 200 0 B 0 ms Chrome 77 /favicon.ico GET 200 0 B 0 ms Chrome 77 
A 2019-09-29T09:43:29Z 2019/09/29 09:43:29 [info] 10#10: *1 client 172.17.0.5 closed keepalive connection


revvy
  • 151
  • 3
  • 16
  • It appears you're missing `beta_settings` entry. See: https://cloud.google.com/appengine/docs/flexible/php/using-cloud-sql#setting_connection_strings_and_adding_a_library. You need to bind the CloudSQL instance to your service and then reference the binding from your code. HTH! – DazWilkin Sep 29 '19 at 20:46
  • It's unclear how you were running your app before using CloudSQL, but you'll also need to configure your app to reference the environment variables (`DB_DATABASE`,`DB_USERNAME`,`DB_PASSWORD`) so that it can connect to the database. You'll possibly need to initialize the database too. – DazWilkin Sep 29 '19 at 20:48

1 Answers1

1

If you take a look a the Connecting from App Engine page in the Cloud SQL docs, you'll see you need to add the following in your app.yaml

beta_settings:
  cloud_sql_instances: <INSTANCE_CONNECTION_NAME>

This is what will enable you to use the /cloudsql/INSTANCE_CONNECTION_NAME Unix domain socket.

kurtisvg
  • 3,412
  • 1
  • 8
  • 24
  • I realised the problem was easier to resolve after I enable error reporting in PHP. I am now faced with the same problem as https://stackoverflow.com/questions/58087153/laravel-with-app-engine-standard-class-facade-ignition-ignitionserviceprovider but could not resolve it even with the author's solution. – revvy Oct 10 '19 at 00:13