systemctl奇怪的错误:无效的参数

时间:2017-02-13 12:10:23

标签: django ubuntu systemctl daphne

这是我的服务文件:

[Unit]
Description=Daphne Interface

[Service]
ExecStartPre=cd /home/git/hsfzmun/server
ExecStart=/bin/bash/ -c "cd /home/git/hsfzmun/server && /home/git/virtualenvs/hsfzmun/bin/daphne -b 0.0.0.0 -p 8001 -v2 config.asgi:channel_layer"
Restart=always
KillSignal=SIGQUIT
Type=notify
NotifyAccess=all

[Install]
WantedBy=multi-user.target

当我执行sudo systemctl start daphnei时,我得到:

Failed to start daphnei.service: Unit daphnei.service is not loaded properly: Invalid argument.
See system logs and 'systemctl status daphnei.service' for details.

systemctl status daphnei.service的结果:

* daphnei.service - Daphne Interface
   Loaded: error (Reason: Invalid argument)
   Active: inactive (dead) (Result: exit-code) since Mon 2017-02-13 19:55:10 CST; 13min ago
 Main PID: 16667 (code=exited, status=1/FAILURE)

出了什么问题?我正在使用Ubuntu Server 16.04。

2 个答案:

答案 0 :(得分:4)

通常,要调试“无效参数”的确切原因,可以使用:

sudo systemd-analyze verify daphnei.service

或在用户本地服务的情况下:

sudo systemd-analyze --user verify daphnei.service

答案 1 :(得分:1)

也许您现在已经弄明白了,但在//bin/bash之后还有ExecStart。{/ p>

我可能有一个稍微更新版本的systemd - 当我尝试时,systemctl status的输出中包含以下消息:

Executable path specifies a directory, ignoring: /bin/bash/ -c "cd /home/git/hsfzmun/server && /home/git/virtualenvs/hsfzmun/bin/daphne -b 0.0.0.0 -p 8001 -v2 config.asgi:channel_layer"

此外,您可以考虑在服务中使用WorkingDirectory行,而不是cd &&