Получение ошибки 500 после развертывания Flask приложения на elasti c beanstalk - PullRequest
0 голосов
/ 06 мая 2020

Я пытаюсь развернуть свое приложение Flask на EB.

При попытке доступа после развертывания я получаю «Internal Server Error».

Это журнал:



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-файл, я выбираю файлы внутри папки root, а не архивирую саму папку.

Я не использую eb cli, поэтому у меня нет папки .ebconfig в проекте. Но даже когда я добавил его, это не сработало.

Я создаю приложение FE с angular 5, собираю его и помещаю html в шаблон, а другие файлы в stati c.

В локальном режиме приложение работает нормально. Буду признателен за любую помощь.

Спасибо

1 Ответ

0 голосов
/ 06 мая 2020

Я использовал команду eb cli для создания папки .elasticbeanstalk + config.yml. Это решило мою проблему.

...