Peter Veselinović
Peter Veselinović

Reputation: 167

How to deploy flask socket application to google cloud

My web_app.py has the following content (only most relevant information included):

app = Flask(__name__)
socketio = SocketIO(app, ping_timeout=1200)
if __name__ == "__main__":
    port = int(os.environ.get('PORT', 5000))
    socketio.run(app)

My app.yaml is:

runtime: python
env: flex
entrypoint: gunicorn -b :$PORT web_app:socketio

runtime_config:
  python_version: 3.6

manual_scaling:
  instances: 1
resources:
  cpu: 1
  memory_gb: 0.5
  disk_size_gb: 10
skip_files:
- output/
- data/
- .idea/
- env/

When I run gcloud app deploy I get the following error:

Application object must be callable.

Please help.

Upvotes: 0

Views: 1129

Answers (1)

gr7
gr7

Reputation: 514

In your app.yaml file, when running gunicorn, you have to indicate the name of the flask class of your web app. Here, under deployment, you can find some different options to deploy a Flask-SocketIO server. You should replace entrypoint: gunicorn -b :$PORT web_app:socketio for entrypoint: gunicorn -b :$PORT web_app:app

Upvotes: 1

Related Questions