添加服务 systemctl start gunicorn服务启动失败

发布于 2022-09-11 20:35:29 字数 1032 浏览 11 评论 0

# 项目地址
/home/crime/sites/demo.eosones.com/Myblog
# 虚拟环境
/home/crime/sites/demo.eosones.com/Myblog_env

配置代码

# vim /etc/systemd/system/gunicorn.service

[Unit]
Description=gunicorn daemon
After=network.target

[Service]
User=root
Group=www-data
WorkingDirectory=/home/crime/sites/demo.eosones.com/Myblog
ExecStart=/home/crime/sites/demo.eosones.com/Myblog_env/bin/gunicorn --workers 3 --bind 127.0.0.1:8080 Myblog.wsgi:application

[Install]
WantedBy=multi-user.target

报错信息

Jun 20 17:49:09 VM_0_5_centos systemd[1]: Started gunicorn daemon.
Jun 20 17:49:09 VM_0_5_centos systemd[1]: gunicorn.service: main process exited, code=exited, status=216/GROUP
Jun 20 17:49:09 VM_0_5_centos systemd[1]: Unit gunicorn.service entered failed state.
Jun 20 17:49:09 VM_0_5_centos systemd[1]: gunicorn.service failed.

小白刚接触Linux,求大佬帮忙到底是哪里出错了,直接在虚拟环境中gunicorn --workers 3 --bind 127.0.0.1:8080 Myblog.wsgi:application可以成功启动,添加到systemd就失败。

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

橪书 2022-09-18 20:35:29

这个错误提示信息太少,可能引起错误的原因有多种,一项项排除吧
1、可能是权限问题,把用户组从Group=www-data改成Group=root
2、可能是环境原因,在[Service]下添加一行Environment=SECRET_KEY=secret

清浅ˋ旧时光 2022-09-18 20:35:29

根据你的错误日志,错误码 216 表明 Group=www-data 有问题。
https://freedesktop.org/softw...

你应该避免设置 root 为用户,参考 gunicorn 官方文档做修改
http://docs.gunicorn.org/en/s...

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文