【发布时间】:2020-11-10 15:18:22
【问题描述】:
我最近将我的 Django API 后端部署到 AWS EB 到他们的 Linux 2 系统(确切的平台名称是 Python 3.7 running on 64bit Amazon Linux 2)。
几乎一切都按预期工作,但我的应用程序运行状况为 Severe,经过数小时的调试后,我不知道为什么。
正在使用以下端点(django-health-check 模块)处理应用程序的运行状况检查。
url(r'^ht/', include('health_check.urls'))
100% 的请求的状态代码为 200,但我的整体健康状况如下:
|--------------------|----------------|---------------------------------------------------|
| instance-id | status | cause |
|--------------------|----------------|---------------------------------------------------|
| Overall | Degraded | Impaired services on all instances. |
| i-0eb89f... | Severe | Following services are not running: release. |
|--------------------|----------------|---------------------------------------------------|
最奇怪的是Following services are not running: release.的消息是互联网独有的(似乎以前没有人遇到过这样的问题)。
另一个奇怪的事情是我的/var/log/healthd/daemon.log 文件的内容类似于
W, [2020-07-21T09:00:01.209091 #3467] WARN -- : log file "/var/log/nginx/healthd/application.log.2020-07-21-09" does not exist
时间变化的地方。
最后可能相关的是我在.ebextensions 目录中的单个文件的内容:
option_settings:
"aws:elasticbeanstalk:application:environment":
DJANGO_SETTINGS_MODULE: "app.settings"
"PYTHONPATH": "/var/app/current:$PYTHONPATH"
"aws:elasticbeanstalk:container:python":
WSGIPath: app.wsgi:application
NumProcesses: 3
NumThreads: 20
aws:elasticbeanstalk:environment:proxy:staticfiles:
/static: static
/static_files: static_files
container_commands:
01_migrate:
command: "source /var/app/venv/staging-LQM1lest/bin/activate && python manage.py migrate --noinput"
leader_only: true
packages:
yum:
git: []
postgresql-devel: []
有谁知道如何解决这个问题?最终目标是拥有绿色OK健康。
编辑:最后我切换到Basic 卫生系统,问题突然消失了。不过,我仍然有兴趣解决最初的问题,因为 Enhanced 卫生系统提供了一些好处
【问题讨论】:
-
是负载均衡的环境吗?
-
@Marcin 是的,我也忘了提到我正在使用
Enhanced health reporting and monitoring -
应用程序是否完全按预期工作? /var/log/cloud-init-cmd 等日志不显示错误?
-
@Marcin 我的意思是端点和数据库都工作得很好。我从 EB 控制台下载了完整的日志并浏览了它们。我发现的只是 eb-engine.log 中的 2 个似乎不相关的错误(
[ERROR] nginx: the configuration file /var/proxy/staging/nginx/nginx.conf syntax is ok nginx: configuration file /var/proxy/staging/nginx/nginx.conf test is successful和[ERROR] Created symlink from /etc/systemd/system/multi-user.target.wants/worker.service to /etc/systemd/system/worker.service.)。一个名为cloud-init-cmd的文件甚至不是日志的一部分。 -
@Marcin 我也切换到
Basic卫生系统(而不是Enhanced),问题就消失了。不过,我仍然有兴趣解决原来的问题。
标签: django amazon-web-services amazon-ec2 amazon-elastic-beanstalk health-monitoring