0

I am trying to deploy a simple django app on google cloud app engine. App has basic wsgi and asgi servers where wsgi is serving HTTPS requests and asgi is serving websocket requests. I am following the google app engine tutorial to deploy the app and it gets built and deployed successfully. However, it is unable to find the installed packages on deployed workspace.

These are the steps I am following

gcloud init
virtualenv myenv
source activate myenv/bin/activate
pip install -r requirements.txt
gcloud app deploy

requirements.txt do have gunicorn and daphne and they also gets installed.

This is error I get when I open the deployed app on browser.

2020-12-15 20:48:25 my-service[20201216t014451]  /bin/sh: 1: exec: gunicorn: not found

This is how my app.yaml file looks like

runtime: python38
service: my-service
instance_class: F2

entrypoint: gunicorn -b :$PORT main:app
handlers:
  - url: /.*
    script: auto
    secure: always

inbound_services:
- warmup

automatic_scaling:
  min_instances: 1
  min_idle_instances: 1
  max_instances: 2
  max_idle_instances: 1

I have also tried by passing the exact path in the entrypoint i.e entrypoint: gunicorn -b :$PORT main:app but got the same error

I am calling gcloud app deploy inside my virtualenv but when it gets deployed it is unable to read the installed packages i.e daphne and gunicorn. They both work totally fine on local environment in the same directory with same packages.

I have referred to these questions this and this and tried the answers but nothing worked.

Muhammad Zeeshan
  • 470
  • 7
  • 24
  • 1
    Could you try deploying with `gcloud beta app deploy --no-cache`? Also please take a look at the [following section of the public docs](https://cloud.google.com/appengine/docs/standard/python3/runtime#application_startup) in order to understand how App Engine Standard manages `gunicorn` and the application startup. If the above fails you could try testing with [App Engine Flex](https://cloud.google.com/python/django/flexible-environment). – Daniel Ocando Dec 16 '20 at 08:41
  • Hey. Thanks. I was missing the trick. I used to install dependencies using pip and deploy with the installed dependencies in an environment. My requirements.txt file was residing in a sub folder. However, google app engine just requires the requirements.txt file in the base folder and it installs the dependencies ( along gunicorn ) while building itself. My problem has resolved now. – Muhammad Zeeshan Dec 16 '20 at 08:54
  • 1
    Always glad to help. I'll post the answer for the community and tracking purposes. – Daniel Ocando Dec 16 '20 at 08:59

1 Answers1

1

GAE app engine needs the requirements.txt file in the same directory as app.yaml.

My requirements.txt file was in a sub-folder, that is why google app engine was unable to install gunicorn. I was installing the requirements locally and passing the installed requirements while deploying, but it seems there is no need to install them locally ( except to test changes on local server ).

Muhammad Zeeshan
  • 470
  • 7
  • 24