I'm new to systemd
. just installed lubuntu16.04
.
I have the following systemd
file:
我是systemd的新手。刚安装了lubuntu16.04。我有以下systemd文件:
[Unit]
Description=gunicorn daemon
After=network.target
[Service]
User=jcg
Group=jcg
WorkingDirectory=/home/jcg/venvs/baseball/baseball_stats
ExecStart=/home/jcg/.virtualenvs/baseball/bin/gunicorn -w 3 -b 0.0.0.0:8001 baseball_stats.wsgi
[Install]
WantedBy=multi-user.target
I get this error:
我收到此错误:
jcg@jcg-Inspiron-1011:/var/log$ systemctl status gunicorn
● gunicorn.service - gunicorn daemon
Loaded: loaded (/etc/systemd/system/gunicorn.service; enabled; vendor preset: enabled)
Active: failed (Result: exit-code) since Mon 2016-05-16 13:59:18 EDT; 9min ago
Process: 681 ExecStart=/home/jcg/.virtualenvs/baseball/bin/gunicorn -w 3 -b 0.0.0.0:8001 baseball_stats.wsgi
Main PID: 681 (code=exited, status=200/CHDIR)
May 16 13:59:18 jcg-Inspiron-1011 systemd[1]: Started gunicorn daemon.
May 16 13:59:18 jcg-Inspiron-1011 systemd[1]: gunicorn.service: Main process exited, code=exited, status=200/CH
May 16 13:59:18 jcg-Inspiron-1011 systemd[1]: gunicorn.service: Unit entered failed state.
May 16 13:59:18 jcg-Inspiron-1011 systemd[1]: gunicorn.service: Failed with result 'exit-code'.
But if I run this gunicorn starts
:
但是,如果我运行这个gunicorn开始:
(baseball) jcg@jcg-Inspiron-1011:~/venvs/baseball/baseball_stats$ /home/jcg/.virtualenvs/baseball/bin/gunicorn -w 3 -b 0.0.0.0:8001 baseball_stats.wsgi
What am I missing, or doing wrong?
我错过了什么,或做错了什么?
1 个解决方案
#1
10
For future readers, my problem was caused by not having an environment variable set that was required by my django application. (settings.py reads the environment). When invoking gunicorn from the command line, that environment variable was previously set.
对于未来的读者,我的问题是由于没有我的django应用程序所需的环境变量集。 (settings.py读取环境)。从命令行调用gunicorn时,先前已设置该环境变量。
When using systemd the following is necessary in the gunicorn.service file:
使用systemd时,gunicorn.service文件中需要以下内容:
[Service]
Environment=SECRET_KEY=secret
#1
10
For future readers, my problem was caused by not having an environment variable set that was required by my django application. (settings.py reads the environment). When invoking gunicorn from the command line, that environment variable was previously set.
对于未来的读者,我的问题是由于没有我的django应用程序所需的环境变量集。 (settings.py读取环境)。从命令行调用gunicorn时,先前已设置该环境变量。
When using systemd the following is necessary in the gunicorn.service file:
使用systemd时,gunicorn.service文件中需要以下内容:
[Service]
Environment=SECRET_KEY=secret