Home Google Cloud App - browser in waiting mode
Reply: 0

Google Cloud App - browser in waiting mode

dbill
1#
dbill Published in 2017-12-07 19:58:47Z

There is probably a very simple solution to my problem, but I'm new to Google Cloud so am struggling with this.

I'm testing a variation to the Google Cloud App Engine Python 'Hello World' app (flexible environment) where I add in a database call. Simply it reads a database table and prints a string from one of the table values instead of 'Hello world'. It works fine in my local virtual environment. But after I deploy it using 'gcloud app deploy' and then run it using 'gcloud app browse', the browser is stuck in waiting mode.

Any ideas what I'm doing wrong here?

The log files shows a worker timeout...

    2017-12-03 00:17:26 default[20171202t160834]  [2017-12-03 00:17:26 +0000] [1] [INFO] Starting gunicorn 19.7.1
    2017-12-03 00:17:26 default[20171202t160834]  [2017-12-03 00:17:26 +0000] [1] [INFO] Listening at: http://0.0.0.0:8080 (1)
    2017-12-03 00:17:26 default[20171202t160834]  [2017-12-03 00:17:26 +0000] [1] [INFO] Using worker: sync
    2017-12-03 00:17:26 default[20171202t160834]  [2017-12-03 00:17:26 +0000] [7] [INFO] Booting worker with pid: 7
    2017-12-03 00:17:56 default[20171202t160834]  [2017-12-03 00:17:56 +0000] [1] [CRITICAL] WORKER TIMEOUT (pid:7)
    2017-12-03 00:17:56 default[20171202t160834]  [2017-12-03 00:17:56 +0000] [7] [INFO] Worker exiting (pid: 7)
2017-12-03 00:17:57 default[20171202t160834]  [2017-12-03 00:17:57 +0000] [10] [INFO] Booting worker with pid: 10

This is the code in my main.py... from flask import Flask import MySQLdb as mdb import pandas as pd

app = Flask(__name__)

con = mdb.connect('104.196.253.80', 'dbxxx', 'xxxxx', 'floor');
dfp=pd.read_sql("SELECT * FROM v_pref", con=con)
con.close()

s=dfp.iloc[0]['model']

@app.route('/')
def hello():
    """Return a friendly HTTP greeting."""
    return s


if __name__ == '__main__':
    app.run(host='127.0.0.1', port=8080)
# [END app]

App.yaml

runtime: python
env: flex
entrypoint: gunicorn -b :$PORT main:app

runtime_config:
  python_version: 3

#[START cloudsql_settings]
beta_settings:
    # If using Cloud SQL, uncomment and set this value to the Cloud SQL
    # connection name, e.g.
    #   "project:region:cloudsql-instance"
    # You must also update the values in config.py.
    #
    cloud_sql_instances: "sincere-destiny-187617:us-west1:topright1"
You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.296154 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO