Search code examples
djangoubuntusystemctldaphne

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.


Solution

  • 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 &&