在生产中自动优雅地重新加载 gunicorn

Ada*_*dam 10 deployment bash shell-scripting gunicorn

我有一个自动部署工作流,可以将代码推送到我的生产服务器并触发数据库迁移、静态文件更新等。问题是,没有开发选项--reload,gunicorn 不会自动重新加载代码更改,他们建议不要在生产中使用。相反,则指令的发送HUP信号到masterpid。问题是,我不知道如何masterpid在自动脚本中检索,尽管手动操作很容易。

如何materpid在 bash 脚本中检索gunicorn systemd 进程的值?

jor*_*anm 9

将以下内容添加到 systemd 服务文件中gunicorn,或将其添加为覆盖:

ExecReload=/bin/kill -HUP $MAINPID
Run Code Online (Sandbox Code Playgroud)

然后您可以重新加载systemctl reload gunicorn.

  • 或者更好的是,`gunicorn@application`.... (2认同)