假设你正在运行virtualenv,gunicorn bin应该是这样的:
/var/www/cmdb/venv/bin/gunicorn
</code>
代替
/var/www/test/bin/gunicorn
</code>
无论如何,我在我的系统中使用这样的东西,它工作正常:
[Unit]
Description = SampleApp
After = network.target
[Service]
PIDFile = /run/cmdb/cmdb.pid
WorkingDirectory = /var/www/cmdb
ExecStartPre = /bin/mkdir /run/cmdb
ExecStart = /var/www/cmdb/venv/bin/gunicorn test.wsgi:application -b 0.0.0.0:8000 —pid /run/cmdb/cmdb.pid
ExecReload = /bin/kill -s HUP $MAINPID
ExecStop = /bin/kill -s TERM $MAINPID
ExecStopPost = /bin/rm -rf /run/cmdb
[Install]
WantedBy = multi-user.target
</code>
注意:此示例使用root作为app用户。我建议您使用具有受限权限的应用程序的用户。