linux - Fabric 1 重新加载 gunicorn.service 返回代码 1
问题描述
我有一个 fabric(1.14.1) 脚本,我执行该脚本以部署在 ec2 实例上。我在单个实例上运行了两个 Web 应用程序(审查和演示)。当我部署应用程序的审查版本时,结构脚本可以正确运行。但是当我为演示运行相同的 fab 脚本时,它会一直运行到最后一个任务的期望,即重新加载 gunicorn 服务。
下面是fab任务
@task
def reload_gunicorn():
print("Reloading Gunicorn...")
sudo("systemctl reload {}".format(get_env("gunicorn_service", "gunicorn.service")))
上面的 gunicorn_service 运行下面的代码,即重新加载 gunicorn。
[Service]
Type=notify
User=web
Group=web
WorkingDirectory=/opt/demo-site/code
ExecStart=/opt/demo-site/env/bin/gunicorn -w 2 -t 60 -b 127.0.0.1:8001 wsgi:application
ExecReload=/bin/kill -s HUP $MAINPID
KillMode=mixed
TimeoutStopSec=5
此版本的演示服务文件类似于位于同一服务器但位置/名称/端口不同的审阅服务文件。现在,当我运行此演示结构部署时,出现以下错误。
[admin@example.com] out: Job for gunicorn-demo.service invalid.
[admin@example.com] out:
Fatal error: sudo() received nonzero return code 1 while executing!
Requested: systemctl reload gunicorn-demo.service
Executed: sudo -S -p 'sudo password:' /bin/bash -l -c "systemctl reload gunicorn-demo.service"
当我在 gunicorn-demo.service 上执行sytemctl 状态时,我在下面看到
● gunicorn-demo.service - Demo Gunicorn Server
Loaded: loaded (/etc/systemd/system/gunicorn-demo.service; enabled; vendor preset: disabled)
Active: failed (Result: exit-code) since Thu 2021-09-16 07:18:39 UTC; 1 weeks 0 days ago
Process: 9066 ExecReload=/bin/kill -s HUP $MAINPID (code=exited, status=0/SUCCESS)
Main PID: 13098 (code=exited, status=3)
Status: "Gunicorn arbiter booted"
这是同一个例子。为什么不要求 sudo 密码进行审核(运行成功),但它要求在演示版本的部署中输入密码。我检查了服务器上审查和演示 gunicorn 服务文件的权限。两者都是相同的(-rw-rw-r--)。坚持了一会儿,感谢任何帮助,这很有用。谢谢
解决方案
推荐阅读
- sql - 我如何将 varchar 类型转换为浮动以使用带有 group by 的聚合 sum() 函数
- hyperledger-fabric - ACL:“ImplicitMeta”规则是如何解释的?
- neo4j - Neo.ClientError.Procedure.ProcedureCallFailed
- javascript - 为什么 android webView 不支持 webSocket?
- javascript - 由于 db-calls 在 Promise 中使用异步。如何修复此反模式?
- python - python项目在两个设备上运行不同
- rpa - 当我尝试在 Automation Anywhere 代码中运行 VBScript 文件时出现错误
- ruby-on-rails - 如何测试 mailgun 使用 capybara 发送电子邮件?
- apache-kafka - 使用 kafka 控制台消费者消费时显示无效字符
- laravel - Laravel 的控制器类型有什么区别?