Deploying a Django App to App Engine Flexible Environment

1,219 views
Skip to first unread message

Tas Sóti

unread,
Jan 23, 2017, 12:39:55 PM1/23/17
to Google App Engine
I have difficulties deploying the sample app (GitHub) to the App Engine Flexible Environment based on this official tutorial. 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.

app.yaml
# [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]

As far as I figured it out, the problem is that gunicorn cannot find the app. To my understanding, the entry point should something like this:
entrypoint: gunicorn --chdir=/path/to/the/app -b :$PORT mysite.wsgi

However, I do not know where the app gets deployed on the virtual machine. Additionally, I would expect the App Engine to sort this out on its own.

Any help is appreciated.

Adam (Cloud Platform Support)

unread,
Jan 24, 2017, 3:37:05 PM1/24/17
to google-a...@googlegroups.com
I went through the tutorial again and it deploys fine for me without any modifications to entrypoint. There is no reason to manually edit this, or discover the path where the app gets deployed on the VM, as this is indeed handled by the runtime.

It appears the mysite/ directory and contents are not being deployed with the app. Can share the output of 'pwd', 'ls' and 'ls mysite/' from inside the directory containing your app.yaml?

Tas Sóti

unread,
Jan 25, 2017, 5:04:21 AM1/25/17
to Google App Engine
Hello Adam,

Thank you for your efforts. Do you mean to have these outputs from the server (so connecting to the instance through SSH)? Unfortunately, I cannot find the deployment folder on the instance. Could you point me to the right path?
Or you mean to have these information from my local drive? I am using Windows, so I cannot give you those outputs. However, I use the unchanged app folder/files directly downloaded from GitHub.

Thank you in advance.

Tas Sóti

unread,
Jan 25, 2017, 5:17:44 AM1/25/17
to Google App Engine
I have just noticed that I get the following warning during the deployment:
WARNING: Could not generate [source-context.json]: Could not list remote URLs from source directory: C:\_Downloads\django_cloudsql

On more thing, the sample is not completely unchanged. I commented out the following two lines from app.yaml:
beta_settings:
    cloud_sql_instances: <your-cloudsql-connection-string>

However, I do not think this is connected to the problem in any way.

Adam (Cloud Platform Support)

unread,
Jan 27, 2017, 3:55:29 PM1/27/17
to Google App Engine
I was referring to your local files. There's no reason to try to discover them on the instance. If you're on Windows, the equivalent commands are echo %cd%, dir, and dir mysite/ from inside the directory containing your app.yaml.

It seems like the files are missing or unreadable, so I'd like to verify they are actually there. If you're on Windows it could also be a permissions issue - try from a folder under C:\Users\<your_username> instead of C:\_Downloads. It can also help to know which version of Windows you're on.

Tas Sóti

unread,
Jan 30, 2017, 11:03:02 AM1/30/17
to Google App Engine
Hello Adam,

Thanks to your hint I started thinking about alternative solutions, and I have figured out that I had a slightly older Google Cloud SDK version (138.0.0). After updating to the newest one (141.0.0), the deployment worked.
Thanks for the help. 

Best,
 Tas
Reply all
Reply to author
Forward
0 new messages