应用实例崩溃:APP / PROC / WEB:退出,状态为127

时间:2019-05-31 17:39:48

标签: python-3.x ibm-cloud cloudfoundry

我正在使用Flask python(我正在使用Python 3.6.8)网络应用程序,但是当我运行命令“ cf push”或“ ibmcloud app push”时,程序无法启动应用程序(等待应用启动... 开始失败)

app.py:

#!/usr/bin/env python3
# -*- coding: utf-8 -*-
""" Main module """
import os
import cf_deployment_tracker
from datetime import datetime
from flask import Flask, render_template, request, Response, make_response, abort
from flask_httpauth import HTTPBasicAuth
from dotenv import load_dotenv

# Emit Bluemix deployment event
cf_deployment_tracker.track()

app = Flask(__name__)

# define basic auth
auth = HTTPBasicAuth()

# On Bluemix, get the port number from the environment variable PORT
# When running this app on the local machine, default the port to 8000
port = int(os.getenv('PORT', 8000))

if __name__ == '__main__':
    load_dotenv(os.path.join(os.path.dirname(__file__), ".env"))

@app.route('/')
def home():
    return "Hello world!"

###################### /API ENDPOINTS ##############################
if __name__ == '__main__':
    app.run(host='0.0.0.0', port=port, debug=True, threaded=True)

setup.py:

# Always prefer setuptools over distutils
from setuptools import setup, find_packages

setup(
    name='hello-world',
    version='1.0.0',
    url='',
    license='Apache-2.0'
)

manifest.yml:

--- 
applications:
 - name: hello-world
   memory: 256MB
   stack:  cflinuxfs3
   buildpack:  https://github.com/cloudfoundry/buildpack-python.git

requirements.txt:

cf-deployment-tracker==1.0.5
Flask==0.12.1
Flask-HTTPAuth==3.2.4
python-dotenv==0.9.1

runtime.txt:

python-3.6.8

Procfile:

web: python app.py

有CF事件:

2019-05-31T09:28:06.00-0600   app.crash                  liza-speakfreely   index: 0, reason: CRASHED, cell_id: d3330ee1-fbaf-4a02-b5bd-cadb9f384f63, instance: fec4b3fc-5d18-4236-74e2-9a38, exit_description: APP/PROC/WEB: Exited with status 127
2019-05-31T09:28:06.00-0600   audit.app.process.crash    web                index: 0, reason: CRASHED, cell_id: d3330ee1-fbaf-4a02-b5bd-cadb9f384f63, instance: fec4b3fc-5d18-4236-74e2-9a38, exit_description: APP/PROC/WEB: Exited with status 127

还有日志:

2019-05-31T11:09:45.99-0600 [CELL/0] OUT Cell ed57f560-073e-48e1-a5b8-e42888f07850 creating container for instance 49f46b7b-57ae-4479-5297-e47e
2019-05-31T11:09:50.84-0600 [CELL/0] OUT Cell ed57f560-073e-48e1-a5b8-e42888f07850 successfully created container for instance 49f46b7b-57ae-4479-5297-e47e
2019-05-31T11:09:57.74-0600 [CELL/0] OUT Starting health monitoring of container
2019-05-31T11:10:07.10-0600 [APP/PROC/WEB/0] ERR  * Running on http://0.0.0.0:8080/ (Press CTRL+C to quit)
2019-05-31T11:10:07.23-0600 [APP/PROC/WEB/0] ERR  * Restarting with stat
2019-05-31T11:10:07.30-0600 [APP/PROC/WEB/0] ERR /usr/bin/env: ‘python3\r’: No such file or directory
2019-05-31T11:10:08.18-0600 [APP/PROC/WEB/0] OUT Exit status 127
2019-05-31T11:10:08.22-0600 [CELL/SSHD/0] OUT Exit status 0
2019-05-31T11:10:14.38-0600 [CELL/0] OUT Cell ed57f560-073e-48e1-a5b8-e42888f07850 stopping instance 49f46b7b-57ae-4479-5297-e47e
2019-05-31T11:10:14.38-0600 [CELL/0] OUT Cell ed57f560-073e-48e1-a5b8-e42888f07850 destroying container for instance 49f46b7b-57ae-4479-5297-e47e
2019-05-31T11:10:14.44-0600 [API/15] OUT Process has crashed with type: "web"
2019-05-31T11:10:14.46-0600 [API/15] OUT App instance exited with guid f48a4d09-f515-4c8c-8f6e-f416c50f496d payload: {"instance"=>"49f46b7b-57ae-4479-5297-e47e", "index"=>0, "cell_id"=>"ed57f560-073e-48e1-a5b8-e42888f07850", "reason"=>"CRASHED", "exit_description"=>"APP/PROC/WEB: Exited with status 127", "crash_count"=>13, "crash_timestamp"=>1559322614375644796, "version"=>"48ca89cd-deaf-42dc-be23-699ef02a2c70"}
2019-05-31T11:10:14.74-0600 [PROXY/0] OUT Exit status 137
2019-05-31T11:10:16.70-0600 [CELL/0] OUT Cell ed57f560-073e-48e1-a5b8-e42888f07850 successfully destroyed container for instance 49f46b7b-57ae-4479-5297-e47e
2019-05-31T11:26:27.87-0600 [CELL/0] OUT Cell 64b8fbdd-c811-404e-a739-d7b7de546dcb creating container for instance 9e03bf72-5d07-45a8-7c93-244f
2019-05-31T11:26:28.95-0600 [CELL/0] OUT Cell 64b8fbdd-c811-404e-a739-d7b7de546dcb successfully created container for instance 9e03bf72-5d07-45a8-7c93-244f
2019-05-31T11:26:33.78-0600 [CELL/0] OUT Starting health monitoring of container
2019-05-31T11:26:34.82-0600 [APP/PROC/WEB/0] ERR  * Running on http://0.0.0.0:8080/ (Press CTRL+C to quit)
2019-05-31T11:26:34.82-0600 [APP/PROC/WEB/0] ERR  * Restarting with stat
2019-05-31T11:26:34.82-0600 [APP/PROC/WEB/0] ERR /usr/bin/env: ‘python3\r’: No such file or directory
2019-05-31T11:26:34.89-0600 [APP/PROC/WEB/0] OUT Exit status 127
2019-05-31T11:26:34.89-0600 [CELL/SSHD/0] OUT Exit status 0
2019-05-31T11:26:41.42-0600 [CELL/0] OUT Cell 64b8fbdd-c811-404e-a739-d7b7de546dcb stopping instance 9e03bf72-5d07-45a8-7c93-244f
2019-05-31T11:26:41.42-0600 [CELL/0] OUT Cell 64b8fbdd-c811-404e-a739-d7b7de546dcb destroying container for instance 9e03bf72-5d07-45a8-7c93-244f
2019-05-31T11:26:41.48-0600 [API/26] OUT Process has crashed with type: "web"
2019-05-31T11:26:41.50-0600 [API/26] OUT App instance exited with guid f48a4d09-f515-4c8c-8f6e-f416c50f496d payload: {"instance"=>"9e03bf72-5d07-45a8-7c93-244f", "index"=>0, "cell_id"=>"64b8fbdd-c811-404e-a739-d7b7de546dcb", "reason"=>"CRASHED", "exit_description"=>"APP/PROC/WEB: Exited with status 127", "crash_count"=>14, "crash_timestamp"=>1559323601416178033, "version"=>"48ca89cd-deaf-42dc-be23-699ef02a2c70"}
2019-05-31T11:26:41.62-0600 [PROXY/0] OUT Exit status 137
2019-05-31T11:26:42.75-0600 [CELL/0] OUT Cell 64b8fbdd-c811-404e-a739-d7b7de546dcb successfully destroyed container for instance 9e03bf72-5d07-45a8-7c93-244f

2 个答案:

答案 0 :(得分:0)

尝试更改

#!/usr/bin/env python3

#!/usr/bin/python3

答案 1 :(得分:0)

我已经进行了更改,但是在上传程序时仍然遇到问题,

#!/usr/bin/python3

我意识到现在可以在日志文件中更改问题了
日志的第一部分:

2019-05-31T12:27:24.52-0600 [STG/0] OUT        Installing collected packages: cf-deployment-tracker, click, MarkupSafe, Jinja2, itsdangerous, Werkzeug, Flask, Flask-HTTPAuth, python-dotenv
2019-05-31T12:27:25.53-0600 [STG/0] ERR          The script flask is installed in '/tmp/contents665937504/deps/0/python/bin' which is not on PATH.
2019-05-31T12:27:25.53-0600 [STG/0] ERR          Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.
2019-05-31T12:27:25.58-0600 [STG/0] ERR          The script dotenv is installed in '/tmp/contents665937504/deps/0/python/bin' which is not on PATH.
2019-05-31T12:27:25.59-0600 [STG/0] ERR          Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.
2019-05-31T12:27:25.60-0600 [STG/0] OUT        Successfully installed Flask-0.12.1 Flask-HTTPAuth-3.2.4 Jinja2-2.10.1 MarkupSafe-1.1.1 Werkzeug-0.15.4 cf-deployment-tracker-1.0.5 click-7.0 itsdangerous-1.1.0 python-dotenv-0.9.1

日志的第二部分:

2019-05-31T12:27:59.60-0600 [STG/0] OUT Cell fed0bcfa-ec8a-468b-b5c1-97398b934fb6 stopping instance 5a9cf419-660b-47cb-af7d-646441d6fd6c
2019-05-31T12:27:59.60-0600 [STG/0] OUT Cell fed0bcfa-ec8a-468b-b5c1-97398b934fb6 destroying container for instance 5a9cf419-660b-47cb-af7d-646441d6fd6c
2019-05-31T12:28:01.18-0600 [CELL/0] OUT Cell e7591558-a990-4351-b550-587ad0822bb2 creating container for instance 5388d93b-0ff2-47a1-6fd7-2448
2019-05-31T12:28:02.15-0600 [CELL/0] OUT Cell e7591558-a990-4351-b550-587ad0822bb2 successfully created container for instance 5388d93b-0ff2-47a1-6fd7-2448
2019-05-31T12:28:02.85-0600 [STG/0] OUT Cell fed0bcfa-ec8a-468b-b5c1-97398b934fb6 successfully destroyed container for instance 5a9cf419-660b-47cb-af7d-646441d6fd6c
2019-05-31T12:28:11.81-0600 [CELL/0] OUT Starting health monitoring of container
2019-05-31T12:28:12.99-0600 [APP/PROC/WEB/0] ERR  * Running on http://0.0.0.0:8080/ (Press CTRL+C to quit)
2019-05-31T12:28:12.99-0600 [APP/PROC/WEB/0] ERR  * Restarting with stat
2019-05-31T12:28:13.00-0600 [APP/PROC/WEB/0] ERR Traceback (most recent call last):
2019-05-31T12:28:13.00-0600 [APP/PROC/WEB/0] ERR   File "app.py", line 32, in <module>
2019-05-31T12:28:13.00-0600 [APP/PROC/WEB/0] ERR     app.run(host='0.0.0.0', port=port, debug=True, threaded=True)
2019-05-31T12:28:13.00-0600 [APP/PROC/WEB/0] ERR   File "/home/vcap/deps/0/python/lib/python3.6/site-packages/flask/app.py", line 841, in run
2019-05-31T12:28:13.00-0600 [APP/PROC/WEB/0] ERR     run_simple(host, port, self, **options)
2019-05-31T12:28:13.00-0600 [APP/PROC/WEB/0] ERR   File "/home/vcap/deps/0/python/lib/python3.6/site-packages/werkzeug/serving.py", line 1007, in run_simple
2019-05-31T12:28:13.00-0600 [APP/PROC/WEB/0] ERR     run_with_reloader(inner, extra_files, reloader_interval, reloader_type)
2019-05-31T12:28:13.00-0600 [APP/PROC/WEB/0] ERR   File "/home/vcap/deps/0/python/lib/python3.6/site-packages/werkzeug/_reloader.py", line 332, in run_with_reloader
2019-05-31T12:28:13.00-0600 [APP/PROC/WEB/0] ERR     sys.exit(reloader.restart_with_reloader())
2019-05-31T12:28:13.00-0600 [APP/PROC/WEB/0] ERR   File "/home/vcap/deps/0/python/lib/python3.6/site-packages/werkzeug/_reloader.py", line 176, in restart_with_reloader
2019-05-31T12:28:13.00-0600 [APP/PROC/WEB/0] ERR     exit_code = subprocess.call(args, env=new_environ, close_fds=False)
2019-05-31T12:28:13.00-0600 [APP/PROC/WEB/0] ERR   File "/home/vcap/deps/0/python/lib/python3.6/subprocess.py", line 287, in call
2019-05-31T12:28:13.00-0600 [APP/PROC/WEB/0] ERR     with Popen(*popenargs, **kwargs) as p:
2019-05-31T12:28:13.00-0600 [APP/PROC/WEB/0] ERR   File "/home/vcap/deps/0/python/lib/python3.6/subprocess.py", line 729, in __init__
2019-05-31T12:28:13.00-0600 [APP/PROC/WEB/0] ERR     restore_signals, start_new_session)
2019-05-31T12:28:13.00-0600 [APP/PROC/WEB/0] ERR   File "/home/vcap/deps/0/python/lib/python3.6/subprocess.py", line 1364, in _execute_child
2019-05-31T12:28:13.00-0600 [APP/PROC/WEB/0] ERR     raise child_exception_type(errno_num, err_msg, err_filename)
2019-05-31T12:28:13.00-0600 [APP/PROC/WEB/0] ERR FileNotFoundError: [Errno 2] No such file or directory: '/home/vcap/app/app.py': '/home/vcap/app/app.py'
2019-05-31T12:28:13.10-0600 [APP/PROC/WEB/0] OUT Exit status 1
2019-05-31T12:28:13.12-0600 [CELL/SSHD/0] OUT Exit status 0
2019-05-31T12:28:19.67-0600 [CELL/0] OUT Cell e7591558-a990-4351-b550-587ad0822bb2 stopping instance 5388d93b-0ff2-47a1-6fd7-2448
2019-05-31T12:28:19.67-0600 [CELL/0] OUT Cell e7591558-a990-4351-b550-587ad0822bb2 destroying container for instance 5388d93b-0ff2-47a1-6fd7-2448
2019-05-31T12:28:20.03-0600 [PROXY/0] OUT Exit status 137
2019-05-31T12:28:20.17-0600 [API/3] OUT Process has crashed with type: "web"
2019-05-31T12:28:20.21-0600 [API/3] OUT App instance exited with guid aabc42d8-3910-42f2-8c4f-726488c11365 payload: {"instance"=>"5388d93b-0ff2-47a1-6fd7-2448", "index"=>0, "cell_id"=>"e7591558-a990-4351-b550-587ad0822bb2", "reason"=>"CRASHED", "exit_description"=>"APP/PROC/WEB: Exited with status 1", "crash_count"=>1, "crash_timestamp"=>1559327299625883843, "version"=>"3418bb3d-bee0-4660-a7c7-a145167d1646"}