Cancel
Showing results for 
Search instead for 
Did you mean: 

Not able to deploy python flask application

Experimenter
Experimenter

I am getting below response while cf push  python flask application in mindshpere.

 

2019-07-04T18:45:47.45+0530 [APP/PROC/WEB/0] OUT * Serving Flask app "fftProcessor_mindsphere.py"
2019-07-04T18:45:47.45+0530 [APP/PROC/WEB/0] OUT * Environment: production
2019-07-04T18:45:47.45+0530 [APP/PROC/WEB/0] OUT WARNING: This is a development server. Do not use it in a production deployment.
2019-07-04T18:45:47.45+0530 [APP/PROC/WEB/0] OUT Use a production WSGI server instead.
2019-07-04T18:45:47.45+0530 [APP/PROC/WEB/0] OUT * Debug mode: off
2019-07-04T18:45:49.46+0530 [APP/PROC/WEB/0] ERR * Running on http://127.0.0.1:5000/ (Press CTRL+C to quit)
2019-07-04T18:46:47.25+0530 [CELL/0] ERR Failed to make TCP connection to port 8080: connection refused
2019-07-04T18:46:47.25+0530 [CELL/0] ERR Timed out after 1m0s: health check never passed.
2019-07-04T18:46:47.28+0530 [APP/PROC/WEB/0] OUT Exit status 143
2019-07-04T18:46:47.41+0530 [CELL/0] OUT Cell 73fefc51-267e-4680-bb25-9567baa79693 stopping instance 390d58f2-2523-4574-4e90-5be6
2019-07-04T18:46:47.41+0530 [CELL/0] OUT Cell 73fefc51-267e-4680-bb25-9567baa79693 destroying container for instance 390d58f2-2523-4574-4e90-5be6
2019-07-04T18:46:48.34+0530 [CELL/0] OUT Cell 73fefc51-267e-4680-bb25-9567baa79693 successfully destroyed container for instance 390d58f2-2523-4574-4e90-5be6

 

 

 

2 REPLIES 2

Re: Not able to deploy python flask application

Legend
Legend

CloudFoundry is killing your container because it's not able to reach the health endpoint that you must expose. Just check the linked docs:

 

https://developer.mindsphere.io/concepts/concept-cloudfoundry-apps.html#monitoring

 

Re: Not able to deploy python flask application

Genius
Genius

Exactly as dlouzan mentioned.

 

The problem might be that you are trying to run a debug server with the port pre-defined on Cloud Foundry. Try running the server like below:

 

#test if env is in cloud foundry by getting VCAP port
try:
    port = int(os.getenv("PORT"))
except:
    if __name__ == "__main__":
        #appEnv = "debug mode"
        app.run(debug='true')

if __name__ == "__main__":
    #appEnv = "Cloud Foundry"
    app.run(host='0.0.0.0', port=port)