0
votes

I am trying to deploy a sample app to the Google App Engine Flexible Environment based on this tutorial. The deployment works, however, the application cannot start up. I get the following error message:

Updating service [default]...failed.
ERROR: (gcloud.app.deploy) Error Response: [9]
Application startup error:
[2017-01-21 17:01:14 +0000] [5] [INFO] Starting gunicorn 19.6.0
[2017-01-21 17:01:14 +0000] [5] [INFO] Listening at: http://0.0.0.0:8080 (5)
[2017-01-21 17:01:14 +0000] [5] [INFO] Using worker: sync
[2017-01-21 17:01:14 +0000] [8] [INFO] Booting worker with pid: 8
[2017-01-21 17:01:14 +0000] [8] [ERROR] Exception in worker process
Traceback (most recent call last):
  File "/env/lib/python3.5/site-packages/gunicorn/arbiter.py", line 557, in spawn_worker
    worker.init_process()
  File "/env/lib/python3.5/site-packages/gunicorn/workers/base.py", line 126, in init_process
    self.load_wsgi()
  File "/env/lib/python3.5/site-packages/gunicorn/workers/base.py", line 136, in load_wsgi
    self.wsgi = self.app.wsgi()
  File "/env/lib/python3.5/site-packages/gunicorn/app/base.py", line 67, in wsgi
    self.callable = self.load()
  File "/env/lib/python3.5/site-packages/gunicorn/app/wsgiapp.py", line 65, in load
    return self.load_wsgiapp()
  File "/env/lib/python3.5/site-packages/gunicorn/app/wsgiapp.py", line 52, in load_wsgiapp
    return util.import_app(self.app_uri)
  File "/env/lib/python3.5/site-packages/gunicorn/util.py", line 357, in import_app
    __import__(module)
ImportError: No module named 'mysite'
[2017-01-21 17:01:14 +0000] [8] [INFO] Worker exiting (pid: 8)
[2017-01-21 17:01:14 +0000] [5] [INFO] Shutting down: Master
[2017-01-21 17:01:14 +0000] [5] [INFO] Reason: Worker failed to boot.

As you can see on GitHub (see link above), the /app.yaml file looks like this:

# [START runtime]
runtime: python
env: flex
entrypoint: gunicorn -b :$PORT mysite.wsgi

beta_settings:
    cloud_sql_instances: <your-cloudsql-connection-string>

runtime_config:
  python_version: 3
# [END runtime]

And the /mysite/wsgi.py file like this:

import os

from django.core.wsgi import get_wsgi_application

os.environ.setdefault("DJANGO_SETTINGS_MODULE", "mysite.settings")

application = get_wsgi_application()

Since the Flexible Environment is in beta, I am not sure if this might be a bug. However, I am using the original app from GitHub without any changes following the official documentation, so I would expect it to work.

I appreciate your help.

3

3 Answers

0
votes

Try:

entrypoint: gunicorn -b :$PORT mysite.wsgi:application

(assuming the directory "mysite" is at the same level as app.yaml. If wsgi.py is at the same level as app.yaml, then just: :$PORT wsgi:application)

0
votes

Thanks to the hint from Adam (Google Cloud Platform team member on the Google Group Forum) that the files are probably not getting deployed, I updated the Google Cloud SDK from 138.0.0 to 141.0.0. Now everything works fine as described in the tutorial.

0
votes

Ensure that your requirements have been met, i.e. copy requirements.txt to the root of your project

https://github.com/GoogleCloudPlatform/python-docs-samples/blob/master/appengine/flexible/django_cloudsql/requirements.txt

which looks like this

Django==1.11.1
mysqlclient==1.3.10
wheel==0.29.0
gunicorn==19.7.1
psycopg2==2.7.1

and run

pip install -r requirements.txt

Then gcloud app deploy