如何解决AWS Elastic Beanstalk Django 网站不会显示
我已经使用 Django 1.11 设置了 python3.6/Amazon Linux 的 Elastic Beanstalk。 该应用程序已通过 EB CLI 成功上传并安装。
INFO deploying new version to instance(s).
INFO New application version was deployed to running EC2 instances.
INFO Environment update completed successfully.
option_settings:
aws:elasticbeanstalk:application:environment:
DJANGO_SETTINGS_MODULE: myproject.settings
SECRET_KEY: TempKey
aws:elasticbeanstalk:container:python:
WsgiPath: myproject/wsgi.py
EB 可以很好地解析 wsgi.py。
我已经在 ALLOWED_HOSTS 中包含了当前的 EB 地址(如 projectname.us-west-1.elasticbeanstalk.com)。
然而,在所有这些“无错误”过程之后,实际的网站并没有出现。 (而 EB 示例应用程序正在运行)甚至根本没有 400、500 错误消息页面。无论 DEBUG=True 还是 False,都没有 Django 错误消息。只是浏览器显示一个空白的超时页面。
当我使用 python manage.py runserver
在本地环境中运行 Django 时,它运行良好。
-------------------------------------
/var/log/httpd/error_log
-------------------------------------
[mpm_prefork:notice] [pid 3150] AH00169: caught SIGTERM,shutting down
[suexec:notice] [pid 20456] AH01232: suEXEC mechanism enabled (wrapper: /usr/sbin/suexec)
[so:warn] [pid 20456] AH01574: module wsgi_module is already loaded,skipping
[http2:warn] [pid 20456] AH10034: The mpm module (prefork.c) is not supported by mod_http2. The mpm determines how things are processed in your server. HTTP/2 has more demands in this regard and the currently selected mpm will just not do. This is an advisory warning. Your server will continue to work,but the HTTP/2 protocol will be inactive.
[http2:warn] [pid 20456] AH02951: mod_ssl does not seem to be enabled
[lbmethod_heartbeat:notice] [pid 20456] AH02282: No slotmem from mod_heartmonitor
[:warn] [pid 20456] mod_wsgi: Compiled for Python/3.6.2.
[:warn] [pid 20456] mod_wsgi: Runtime using Python/3.6.12.
[mpm_prefork:notice] [pid 20456] AH00163: Apache/2.4.46 (Amazon) mod_wsgi/3.5 Python/3.6.12 configured -- resuming normal operations
[core:notice] [pid 20456] AH00094: Command line: '/usr/sbin/httpd -D FOREGROUND'
-------------------------------------
/opt/python/log/supervisord.log
-------------------------------------
INFO stopped: httpd (exit status 0)
INFO spawned: 'httpd' with pid 20456
INFO success: httpd entered RUNNING state,process has stayed up for > than 1 seconds (startsecs)
-------------------------------------
/var/log/httpd/access_log
-------------------------------------
127.0.0.1 (-) - - [+0000] "GET / HTTP/1.1" 301 - "-" "Python-urllib/2.7"
127.0.0.1 (-) - - [+0000] "GET / HTTP/1.1" 301 - "-" "Python-urllib/2.7"
127.0.0.1 (-) - - [+0000] "GET / HTTP/1.1" 301 - "-" "Python-urllib/2.7"
127.0.0.1 (-) - - [+0000] "GET / HTTP/1.1" 301 - "-" "Python-urllib/2.7"
-------------------------------------
/var/log/eb-activity.log
-------------------------------------
INFO [3223] - [Application deployment app-51cc-29999@52/StartupStage0/EbExtensionPostBuild/Infra-EmbeddedPostBuild] : Starting activity...
INFO [3223] - [Application deployment app-51cc-29999@52/StartupStage0/EbExtensionPostBuild/Infra-EmbeddedPostBuild/postbuild_0_myproject_test_1/Test for Command 01_migrate] : Completed activity. Result:
Completed successfully.
Operations to perform:
Apply all migrations: admin,.....
Running migrations:
No migrations to apply.
INFO [3223] - [Application deployment app-51cc-29999@52/StartupStage0/EbExtensionPostBuild] : Completed activity.
INFO [3223] - [Application deployment app-51cc-29999@52/StartupStage0/InfraCleanEbExtension] : Starting activity...
INFO [3223] - [Application deployment app-51cc-29999@52/StartupStage0/InfraCleanEbExtension] : Completed activity. Result:
Cleaned ebextensions subdirectories from /opt/python/ondeck/app.
INFO [3223] - [Application deployment app-51cc-29999@52/StartupStage0] : Completed activity. Result:
Application deployment - Command CMD-Startup stage 0 completed
INFO [3223] - [Application deployment app-51cc-29999@52/StartupStage1/AppDeployEnactHook/01flip.py] : Completed activity. Result:
httpd: stopped
httpd: started
httpd RUNNING pid 20456,uptime 0:00:03
INFO Apache is running,but root page is not responding in 3 seconds.
INFO [3223] - [Application deployment app-51cc-29999@52/StartupStage1/AppDeployEnactHook/02create_pids_for_monitoring.sh] : Starting activity...
INFO [3223] - [Application deployment app-51cc-29999@52/StartupStage1/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
INFO [3223] - [Application deployment app-51cc-29999@52/StartupStage1/AppDeployEnactHook] : Completed activity. Result:
Successfully execute hooks in directory /opt/elasticbeanstalk/hooks/appdeploy/enact.
INFO [3223] - [Application deployment app-51cc-29999@52/StartupStage1/AppDeployPostHook] : Starting activity...
INFO [3223] - [Application deployment app-51cc-29999@52/StartupStage1/AppDeployPostHook] : Completed activity. Result:
Successfully execute hooks in directory /opt/elasticbeanstalk/hooks/appdeploy/post.
INFO [3223] - [Application deployment app-51cc-29999@52/StartupStage1/PostinitHook] : Starting activity...
INFO [3223] - [Application deployment app-51cc-29999@52/StartupStage1/PostinitHook/01processmgrstart.sh] : Starting activity...
INFO [3223] - [Application deployment app-51cc-29999@52/StartupStage1/PostinitHook/01processmgrstart.sh] : Completed activity. Result:
+ pgrep supervisord
3064
INFO [3223] - [Application deployment app-51cc-29999@52/StartupStage1/PostinitHook] : Completed activity. Result:
Successfully execute hooks in directory /opt/elasticbeanstalk/hooks/postinit.
INFO [3223] - [Application deployment app-51cc-29999@52/StartupStage1] : Completed activity. Result:
Application deployment - Command CMD-Startup stage 1 completed
INFO [3223] - [Application deployment app-51cc-29999@52/AddonsAfter] : Starting activity...
INFO [3223] - [Application deployment app-51cc-29999@52/AddonsAfter/ConfigLogRotation] : Starting activity...
INFO [3223] - [Application deployment app-51cc-29999@52/AddonsAfter/ConfigLogRotation/10-config.sh] : Starting activity...
[2021-01-01T05:23:11.925Z] INFO [3223] - [Application deployment app-51cc-29999@52/AddonsAfter/ConfigLogRotation/10-config.sh] : Completed activity. Result:
disabled forced hourly log rotation.
INFO [3223] - [Application deployment app-51cc-29999@52/AddonsAfter/ConfigLogRotation] : Completed activity. Result:
Successfully execute hooks in directory /opt/elasticbeanstalk/addons/logpublish/hooks/config.
INFO [3223] - [Application deployment app-51cc-29999@52/AddonsAfter] : Completed activity.
INFO [3223] - [Application deployment app-51cc-29999@52] : Completed activity. Result:
Application deployment - Command CMD-Startup succeeded
INFO [20664] - [CMD-TailLogs] : Starting activity...
-------------------------------------
/var/log/eb-commandprocessor.log
-------------------------------------
INFO [3223] : Instance is leader.
DEBUG [3223] : Loaded 7 actions for stage 0.
INFO [3223] : Running stage 1 of command CMD-Startup...
DEBUG [3223] : Loaded 3 actions for stage 1.
INFO [3223] : Command CMD-Startup succeeded!
INFO [3223] : Command processor returning results:
{"status":"SUCCESS","api_version":"1.0","results":[{"status":"SUCCESS","msg":"","returncode":0,"events":[]}]}
DEBUG [20664] : Reading config file: /etc/elasticbeanstalk/.aws-eb-stack.properties
DEBUG [20664] : Checking if the command processor should execute...
DEBUG [20664] : Checking whether the command is applicable to instance (i-007e4078e1a342421)..
INFO [20664] : Command is applicable to this instance (i-007e4078e1a342421)..
DEBUG [20664] : Checking if the received command stage is valid..
INFO [20664] : No stage_num in command. Valid stage..
INFO [20664] : Received command CMD-TailLogs: {"execution_data"=>"*","instance_ids"=>["i-007e4078e1a342421"],"data"=>"dfd6c391-1fa0-433d-916d-2696608b221a","command_name"=>"CMD-TailLogs","api_version"=>"1.0","resource_name"=>"AWSEBAutoScalingGroup","request_id"=>"dfd6c391-1fa0-433d-916d-2696608b221a"}
INFO [20664] : Command processor should execute command.
DEBUG [20664] : Storing current stage..
DEBUG [20664] : Stage_num does not exist. Not saving null stage. Returning..
DEBUG [20664] : Reading config file: /etc/elasticbeanstalk/.aws-eb-stack.properties
DEBUG [20664] : Retrieving Metadata for key: AWS::ElasticBeanstalk::Ext||_ContainerConfigFileContent||commands..
DEBUG [20664] : Retrieving Metadata for key: AWS::ElasticBeanstalk::Ext||_API||_Commands..
INFO [20664] : Found enabled addons: ["logstreaming","logpublish"].
INFO [20664] : Updating Command deFinition of addon logstreaming.
INFO [20664] : Updating Command deFinition of addon logpublish.
DEBUG [20664] : Loaded deFinition of Command CMD-TailLogs.
DEBUG [20664] : Setting environment variables..
一些可疑的部分如下:
INFO [3223] - [Application deployment app-51cc-29999@52/StartupStage1/AppDeployEnactHook/01flip.py] : Completed activity. Result:
httpd: stopped
httpd: started
httpd RUNNING pid 20456,but root page is not responding in 3 seconds.
和,
127.0.0.1 (-) - - [+0000] "GET / HTTP/1.1" 301 - "-" "Python-urllib/2.7"
我尝试在 EC2 SSH 上手动重新启动 httpd,刷新 EB 环境和应用程序,使用 https 和 HTTP,使用 EC2 IP 地址,然后从头开始重新启动,但没有奏效。
有解决问题的线索吗?
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。