I ran into this problem while writing unit-file for one simple daemon. When daemon returns '1' on startup systemd just ignores it, and it looks like daemon was started successfully while it's actually dead.
For example, I have very simple shell script:
#!/bin/bash
exit 1
So unit-file looks like this:
[Unit]
Description=test service
After=syslog.target
[Service]
User=testuser
Group=testuser
ExecStart=/usr/local/bin/return1
[Install]
WantedBy=multi-user.target
Trying to start, seems ok:
# service testservice start
# echo $?
0
But actually it is dead:
# service testservice status
● testservice.service - test service
Loaded: loaded (/etc/systemd/system/testservice.service; enabled)
Active: failed (Result: exit-code) since Fri 2016-01-22 14:51:45 MSK; 1min 13s ago
Process: 16416 ExecStart=/usr/local/bin/return1 (code=exited, status=1/FAILURE)
Main PID: 16416 (code=exited, status=1/FAILURE)
Jan 22 14:51:45 servername systemd[1]: Started test service.
Jan 22 14:51:45 servername systemd[1]: testservice.service: main process exited, code=exited, status=1/FAILURE
Jan 22 14:51:45 servername systemd[1]: Unit testservice.service entered failed state.
It looks like systemd thinks that daemon was started successfully, but crashed later.
I tried to resolve this problem by changing service Type to 'forking' and others - this works fine in a case of non-zero code, but service is actually 'simple', so in a case if successful start it just stays and keeps the terminal busy.
How do I manage this kind of services? Or may be it is necessary to fix something in daemon code?
OS debian 8 x64, systemd 215