Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

systemctl strange error: Invalid arguments

Here's my service file:

[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

When I execute sudo systemctl start daphnei I get:

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

And the result of 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)

What's wrong? I am using Ubuntu Server 16.04.

like image 619
hsfzxjy Avatar asked Feb 13 '17 12:02

hsfzxjy


2 Answers

Generally, to debug exact cause of "Invalid argument", you can use:

sudo systemd-analyze verify daphnei.service

or in case of user's local service:

sudo systemd-analyze --user verify daphnei.service

like image 84
teejay Avatar answered Nov 08 '22 02:11

teejay


Maybe you've figured it out by now, but there's an extra / after /bin/bash in your ExecStart line.

I may have a slightly newer version of systemd -- when I tried it, the output of systemctl status included this message:

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"

Also, you might consider using a WorkingDirectory line in the service, instead of cd &&

like image 6
larcher Avatar answered Nov 08 '22 02:11

larcher