我正在尝试在EB上部署我的Flask应用。
在部署后尝试访问时,出现“内部服务器错误”。
这是日志:
05:23:06
[2020-05-06T05:23:06.465Z] INFO [9428] - [Application update v10@12/AppDeployStage0/AppDeployPreHook/01new.py] : Starting activity...
05:23:06
[2020-05-06T05:23:06.800Z] INFO [9428] - [Application update v10@12/AppDeployStage0/AppDeployPreHook/01new.py] : Completed activity.
05:23:06
[2020-05-06T05:23:06.800Z] INFO [9428] - [Application update v10@12/AppDeployStage0/AppDeployPreHook/02unzip.py] : Starting activity...
05:23:09
[2020-05-06T05:23:07.870Z] INFO [9428] - [Application update v10@12/AppDeployStage0/AppDeployPreHook/02unzip.py] : Completed activity. Result: Archive: /opt/elasticbeanstalk/deploy/appsource/source_bundle inflating: /opt/python/ondeck/app/__init__.py inflating: /opt/python/ondeck/app/__pycache__/__init__.cpython-36.pyc inflating: /opt/python/ondeck/app/__pycache__/application.
05:23:09
[2020-05-06T05:23:07.870Z] INFO [9428] - [Application update v10@12/AppDeployStage0/AppDeployPreHook/03deploy.py] : Starting activity...
05:23:09
[2020-05-06T05:23:08.581Z] INFO [9428] - [Application update v10@12/AppDeployStage0/AppDeployPreHook/03deploy.py] : Completed activity. Result: Requirement already satisfied: click==7.1.2 in /opt/python/run/venv/lib/python3.6/site-packages (from -r /opt/python/ondeck/app/requirements.txt (line 1)) Requirement already satisfied: Flask==1.1.2 in /opt/python/run/venv/lib/python3.6/site-packages
05:23:09
[2020-05-06T05:23:08.581Z] INFO [9428] - [Application update v10@12/AppDeployStage0/AppDeployPreHook/04configen.py] : Starting activity...
05:23:10
[2020-05-06T05:23:09.944Z] INFO [9428] - [Application update v10@12/AppDeployStage0/AppDeployPreHook/04configen.py] : Completed activity.
05:23:10
[2020-05-06T05:23:09.944Z] INFO [9428] - [Application update v10@12/AppDeployStage0/AppDeployPreHook] : Completed activity. Result: Successfully execute hooks in directory /opt/elasticbeanstalk/hooks/appdeploy/pre.
05:23:10
[2020-05-06T05:23:09.944Z] INFO [9428] - [Application update v10@12/AppDeployStage0/EbExtensionPostBuild] : Starting activity...
05:23:11
[2020-05-06T05:23:10.353Z] INFO [9428] - [Application update v10@12/AppDeployStage0/EbExtensionPostBuild/Infra-EmbeddedPostBuild] : Starting activity...
05:23:11
[2020-05-06T05:23:10.353Z] INFO [9428] - [Application update v10@12/AppDeployStage0/EbExtensionPostBuild/Infra-EmbeddedPostBuild] : Completed activity.
05:23:11
[2020-05-06T05:23:10.370Z] INFO [9428] - [Application update v10@12/AppDeployStage0/EbExtensionPostBuild] : Completed activity.
05:23:11
[2020-05-06T05:23:10.370Z] INFO [9428] - [Application update v10@12/AppDeployStage0/InfraCleanEbextension] : Starting activity...
05:23:11
[2020-05-06T05:23:10.376Z] INFO [9428] - [Application update v10@12/AppDeployStage0/InfraCleanEbextension] : Completed activity. Result: Cleaned ebextensions subdirectories from /opt/python/ondeck/app.
05:23:11
[2020-05-06T05:23:10.376Z] INFO [9428] - [Application update v10@12/AppDeployStage0] : Completed activity. Result: Application update - Command CMD-AppDeploy stage 0 completed
05:23:11
[2020-05-06T05:23:10.376Z] INFO [9428] - [Application update v10@12/AppDeployStage1] : Starting activity...
05:23:11
[2020-05-06T05:23:10.376Z] INFO [9428] - [Application update v10@12/AppDeployStage1/AppDeployEnactHook] : Starting activity...
05:23:11
[2020-05-06T05:23:10.377Z] INFO [9428] - [Application update v10@12/AppDeployStage1/AppDeployEnactHook/01flip.py] : Starting activity...
05:23:19
[2020-05-06T05:23:19.219Z] INFO [9428] - [Application update v10@12/AppDeployStage1/AppDeployEnactHook/01flip.py] : Completed activity. Result: httpd: stopped httpd: started httpd RUNNING pid 9656, uptime 0:00:02 2020-05-06 05:23:19,212 INFO Apache is running, but root page is not responding in 3 seconds.
05:23:19
[2020-05-06T05:23:19.219Z] INFO [9428] - [Application update v10@12/AppDeployStage1/AppDeployEnactHook/01stop_xray.sh] : Starting activity...
05:23:19
[2020-05-06T05:23:19.336Z] INFO [9428] - [Application update v10@12/AppDeployStage1/AppDeployEnactHook/01stop_xray.sh] : Completed activity. Result: Executing: if ( initctl status xray | grep start ); then initctl stop xray; fi
05:23:19
[2020-05-06T05:23:19.336Z] INFO [9428] - [Application update v10@12/AppDeployStage1/AppDeployEnactHook/02create_pids_for_monitoring.sh] : Starting activity...
05:23:20
[2020-05-06T05:23:19.445Z] INFO [9428] - [Application update v10@12/AppDeployStage1/AppDeployEnactHook/02create_pids_for_monitoring.sh] : Completed activity. Result: + chmod 0755 /var/run/httpd + /opt/elasticbeanstalk/bin/healthd-track-pidfile --proxy httpd + /opt/elasticbeanstalk/bin/healthd-track-pidfile --name application --location /opt/python/run/supervisord.pid
05:23:20
[2020-05-06T05:23:19.446Z] INFO [9428] - [Application update v10@12/AppDeployStage1/AppDeployEnactHook/02start_xray.sh] : Starting activity...
05:23:20
[2020-05-06T05:23:19.559Z] INFO [9428] - [Application update v10@12/AppDeployStage1/AppDeployEnactHook/02start_xray.sh] : Completed activity.
05:23:20
[2020-05-06T05:23:19.560Z] INFO [9428] - [Application update v10@12/AppDeployStage1/AppDeployEnactHook] : Completed activity. Result: Successfully execute hooks in directory /opt/elasticbeanstalk/hooks/appdeploy/enact.
05:23:20
[2020-05-06T05:23:19.560Z] INFO [9428] - [Application update v10@12/AppDeployStage1/AppDeployPostHook] : Starting activity...
05:23:20
[2020-05-06T05:23:19.560Z] INFO [9428] - [Application update v10@12/AppDeployStage1/AppDeployPostHook] : Completed activity. Result: Successfully execute hooks in directory /opt/elasticbeanstalk/hooks/appdeploy/post.
05:23:20
[2020-05-06T05:23:19.560Z] INFO [9428] - [Application update v10@12/AppDeployStage1] : Completed activity. Result: Application version switch - Command CMD-AppDeploy stage 1 completed
05:23:20
[2020-05-06T05:23:19.560Z] INFO [9428] - [Application update v10@12/AddonsAfter] : Starting activity...
05:23:20
[2020-05-06T05:23:19.560Z] INFO [9428] - [Application update v10@12/AddonsAfter/ConfigLogRotation] : Starting activity...
05:23:20
[2020-05-06T05:23:19.560Z] INFO [9428] - [Application update v10@12/AddonsAfter/ConfigLogRotation/10-config.sh] : Starting activity...
05:23:20
[2020-05-06T05:23:19.642Z] INFO [9428] - [Application update v10@12/AddonsAfter/ConfigLogRotation/10-config.sh] : Completed activity. Result: Enabled forced hourly log rotation.
05:23:20
[2020-05-06T05:23:19.642Z] INFO [9428] - [Application update v10@12/AddonsAfter/ConfigLogRotation] : Completed activity. Result: Successfully execute hooks in directory /opt/elasticbeanstalk/addons/logpublish/hooks/config.
05:23:20
[2020-05-06T05:23:19.642Z] INFO [9428] - [Application update v10@12/AddonsAfter] : Completed activity.
05:23:20
[2020-05-06T05:23:19.642Z] INFO [9428] - [Application update v10@12] : Completed activity. Result: Application update - Command CMD-AppDeploy succeeded
这是代码:
from flask import Flask, render_template, send_from_directory
from flask_mysqldb import MySQL
from flask_cors import CORS, cross_origin
from .views import blueprints
application = Flask(__name__)
application.secret_key = 'password123'
mysql = MySQL(application)
application.mysqlRef = mysql
CORS(application)
for bp in blueprints:
application.register_blueprint(bp)
application.config['MYSQL_USER'] = ''
application.config['MYSQL_PASSWORD'] = ''
application.config['MYSQL_HOST'] = ''
application.config['MYSQL_DB'] = 'heroku****'
application.config['MYSQL_CURSORCLASS'] = 'DictCursor'
@application.route('/<path:path>', methods=['GET'])
def static_proxy(path):
return send_from_directory('./static', path)
@application.route("/")
def hello():
return send_from_directory('./templates', 'index.html')
if __name__ == '__main__':
application.run(host='0.0.0.0', port=5000, debug=True)
我什至试图返回一个字符串作为响应,但没有成功。创建zip文件时,我选择的是根文件夹中的文件,而不是对文件夹本身进行zip。
我不使用eb cli,因此项目中没有.ebconfig文件夹。但是,即使我添加了它,也没有用。
我用角度5构建FE应用程序,对其进行构建,并将html放在模板中,并将其他文件放在静态文件中。
在本地模式下,应用正常运行。我将不胜感激。
谢谢
我使用eb cli创建.elasticbeanstalk文件夹+ config.yml。那解决了我的问题。