12

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.

hsfzxjy
  • 1,242
  • 4
  • 14
  • 22

2 Answers2

18

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

teejay
  • 2,353
  • 2
  • 27
  • 36
  • 1
    "Unknown operation 'verify'" – Matt Jan 26 '19 at 19:00
  • check a man of ur particular systemd-analyze version, it should definitely be a known command and correct syntax: https://www.freedesktop.org/software/systemd/man/systemd-analyze.html – teejay Jan 26 '19 at 22:44
6

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

larcher
  • 183
  • 2
  • 8