【发布时间】:2020-12-24 04:06:59
【问题描述】:
我在 EBS 上苦苦挣扎,因为我认为 EBS 的架构相对简单。我有一个 Django 应用程序。这个 Django 应用程序将包含我的工作环境和我的 WebServer 的代码。我一直很好地部署到 WebServer,并且在我尝试合并它时只有我的工作环境存在这个问题。 This poor chap 有同样的问题,which the community 似乎没有一个好的答案。
这是我学到的第 1 个错误,因为没有很好的方法来分离配置。
从我得到这个错误开始:
2020/09/03 20:17:59.065285 [错误] 更新进程 [web sqsd nginx healthd cfn-hup] pid 符号链接失败并出现错误读取 pid 源文件 /var/pids/web.pid 失败并出现错误:打开 / var/pids/web.pid: 没有这样的文件或目录
来自this link,我认为是由于我的.platform 覆盖了nginx(仅修改gzip 以将其打开)以某种方式导致了这种情况。我已将其删除并重新部署,但错误不存在,因此看起来合乎逻辑。不幸的是,它似乎很喜怒无常,因为它回来了(在我已经部署了几次之后!!!!)。
我第一次尝试解决这个问题是使用saved_configs/
├── .elasticbeanstalk
│ ├── config.yml
│ └── saved_configs
│ ├── web.cfg.yml
│ └── worker.cfg.yml
并这样称呼它:
eb create testweb --cfg web
eb create testwrkr -t worker --cfg worker
eb deploy testweb
eb deploy testwrkr
这似乎可行,但我仍然无法部署我的工作环境。接下来我尝试创建一个 Makefile,因为昨天删除了 .platform 为我修复了错误。
ENVS = 'production development'
ifndef env
$(error "env" is not specified. Please use one of: $(ENVS))
endif
create_web: clean copy_web_configuration
@echo "Creating Environment: $(env)"
-eb create $(env)
create_worker: clean copy_worker_configuration
@echo "Creating Worker Environment: $(env)"
-eb create $(env) -t worker
deploy_web: clean copy_web_configuration
@echo "Deploying to: $(env)"
-eb deploy $(env) $(args)
@$(MAKE) clean
deploy_worker: clean copy_worker_configuration
@echo "Deploying worker to: $(env)"
-eb deploy $(env) $(args)
@$(MAKE) clean
copy_web_configuration:
@cp -r config/ebs/extensions/shared/ .ebextensions/
@cp -r config/ebs/extensions/web/ .ebextensions/
@cp -r config/ebs/platform/web/ .platform/
copy_worker_configuration:
@cp -r config/ebs/extensions/shared/ .ebextensions/
@cp -r config/ebs/extensions/worker/ .ebextensions/
clean:
@find .ebextensions/ -maxdepth 1 -type f -exec rm -f {} \;
@rm -rf .platform/nginx
@find .platform/ -maxdepth 1 -type f -exec rm -f {} \;
所以我可以 100% 确定 .ebextensions/ 或 .platform/ 中的任何内容都是针对预期平台的。
My new file tree looks like this:
.ebextensions/
.platform/
config/
├── __init__.py
├── ebs
│ ├── extensions
│ │ ├── shared
│ │ │ ├── 01_packages.config
│ │ │ ├── appslog.config
│ │ │ └── django.config
│ │ ├── web
│ │ │ ├── db-migrate.config
│ │ │ ├── securelistener-clb.config
│ │ │ └── static.config
│ │ └── worker
│ │ └── worker.config
│ └── platform
│ └── web
│ └── nginx
│ └── nginx.conf
├── settings
│ ├── __init__.py
│ ├── base.py
│ ├── local.py
│ └── production.py
├── urls.py
└── wsgi.py
现在,当我部署时(在添加 cron.yaml 后),我又找到了我的老朋友
2020/09/04 22:12:21.485660 [INFO] 执行指令:跟踪 healthd 中的 pid 2020/09/04 22:12:21.485677 [INFO] 这是一个增强的健康环境... 2020/09/04 22:12:21.485697 [INFO] 运行命令 /bin/sh -c systemctl show -p ConsistsOf aws-eb.target |剪切 -d= -f2 2020/09/04 22:12:21.491871 [INFO] nginx.service healthd.service cfn-hup.service sqsd.service
2020/09/04 22:12:21.491894 [INFO] 运行命令 /bin/sh -c systemctl show -p ConsistsOf eb-app.target |剪切 -d= -f2 2020/09/04 22:12:21.496690 [信息] web.service
2020/09/04 22:12:21.496761 [错误] 更新进程 [web nginx healthd cfn-hup sqsd] pid 符号链接失败并出现错误读取 pid 源文件 /var/pids/web.pid 失败并出现错误:打开 / var/pids/web.pid:没有这样的文件或目录 2020/09/04 22:12:21.496772 [错误] 执行命令 [app-deploy] - [Track pids in healthd] 时出错。停止运行命令。错误:更新进程 [web nginx healthd cfn-hup sqsd] pid 符号链接失败并出现错误读取 pid 源文件 /var/pids/web.pid 失败并出现错误:打开 /var/pids/web.pid:没有这样的文件或目录
2020/09/04 22:12:21.496776 [INFO] 执行清理逻辑 2020/09/04 22:12:21.496861 [INFO] CommandService 响应:{"status":"FAILURE","api_version":"1.0","results":[{"status":"FAILURE","msg" :"引擎执行遇到错误。","returncode":1,"events":[{"msg":"实例部署成功生成了一个'Procfile'。","timestamp":1599257531,"severity":" INFO"},{"msg":"实例部署失败,详情见'eb-engine.log'。","timestamp":1599257541,"severity":"ERROR"}]}]}
我的工作人员配置中没有太多内容,所以我不知道为什么它不会部署。有没有人见过这个问题? 我在网上找到的唯一资源是:
- https://forums.aws.amazon.com/thread.jspa?messageID=955011󩊃(没有答案)
- https://forums.aws.amazon.com/thread.jspa?threadID=326968
我同时监控了日志,按照操作顺序看到首先出现这个错误:
Sep 4 22:42:18 ip-172-31-7-235 web: File "/usr/lib64/python3.7/importlib/__init__.py", line 127, in import_module
Sep 4 22:42:18 ip-172-31-7-235 web: return _bootstrap._gcd_import(name[level:], package, level)
Sep 4 22:42:18 ip-172-31-7-235 web: File "<frozen importlib._bootstrap>", line 1006, in _gcd_import
Sep 4 22:42:18 ip-172-31-7-235 web: File "<frozen importlib._bootstrap>", line 983, in _find_and_load
Sep 4 22:42:18 ip-172-31-7-235 web: File "<frozen importlib._bootstrap>", line 965, in _find_and_load_unlocked
Sep 4 22:42:18 ip-172-31-7-235 web: ModuleNotFoundError: No module named 'application'
Sep 4 22:42:18 ip-172-31-7-235 web: [2020-09-04 22:42:18 +0000] [9303] [INFO] Worker exiting (pid: 9303)
Sep 4 22:42:18 ip-172-31-7-235 web: [2020-09-04 22:42:18 +0000] [9296] [INFO] Shutting down: Master
Sep 4 22:42:18 ip-172-31-7-235 web: [2020-09-04 22:42:18 +0000] [9296] [INFO] Reason: Worker failed to boot.
然后
2020/09/04 22:42:21.717799 [INFO] Running command /bin/sh -c systemctl show -p ConsistsOf eb-app.target | cut -d= -f2
2020/09/04 22:42:21.722604 [INFO] web.service
2020/09/04 22:42:21.722678 [ERROR] update processes [web healthd nginx sqsd cfn-hup] pid symlinks failed with error Read pid source file /var/pids/web.pid failed with error:open /var/pids/web.pid: no such file or directory
2020/09/04 22:42:21.722689 [ERROR] An error occurred during execution of command [app-deploy] - [Track pids in healthd]. Stop running the command. Error: update processes [web healthd nginx sqsd cfn-hup] pid symlinks failed with error Read pid source file /var/pids/web.pid failed with error:open /var/pids/web.pid: no such file or directory
2020/09/04 22:42:21.722694 [INFO] Executing cleanup logic
2020/09/04 22:42:21.722778 [INFO] CommandService Response: {"status":"FAILURE","api_version":"1.0","results":[{"status":"FAILURE","msg":"Engine execution has encountered an error.","returncode":1,"events":[{"msg":"Instance deployment successfully generated a 'Procfile'.","timestamp":1599259331,"severity":"INFO"},{"msg":"Instance deployment failed. For details, see 'eb-engine.log'.","timestamp":1599259341,"severity":"ERROR"}]}]}
所以我猜测没有找到的web.service 是因为ModuleNotFound 错误。我不明白的是我使用的代码库与 Web 环境完全相同。那么 Worker 环境怎么会失败呢?配置对我来说看起来不错。我的树在上面,相关的beantalk配置是这样的:
aws:elasticbeanstalk:container:python:
WSGIPath: config.wsgi:application
【问题讨论】:
-
应用程序的入口点是什么?它应该被称为
application。例如,在烧瓶中显示here 入口点是application = Flask(__name__)。所以我认为你的工作环境也期望你的主文件中有application变量。它找不到它,因此您会收到有关No module named 'application'的错误。 -
感谢您的评论。该变量名为
application,位于config/wsgi.py,所以看起来我的WSGIPath应该没问题。几周以来,我也一直在将配置 + 代码库部署到 Web 环境中,所以看到它让我感到惊讶
标签: amazon-web-services amazon-elastic-beanstalk