# 项目地址
/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就失败。
这个错误提示信息太少,可能引起错误的原因有多种,一项项排除吧
1、可能是权限问题,把用户组从Group=www-data改成Group=root
2、可能是环境原因,在[Service]下添加一行Environment=SECRET_KEY=secret