I have successfully created and configured a systemd template for easily spawning instances of similar services.
the template looks like this:
[Unit] Description=my awesome service %I After=network.target [Service] Type=simple ExecStart=/usr/local/bin/binary -c /path/to/config/%i.conf ExecStop=/usr/bin/pkill --full %i Restart=on-failure User=root Group=root TimeoutSec=30 [Install] WantedBy=multi-user.target
I enabled and started the instance with systemcl enable name@kkk, systemctl start name@kkk and did not create a /path/to/config/kkk.conf file, so the service fails:
~# systemctl status email@example.com ● firstname.lastname@example.org - my awesome service kkk Loaded: loaded (/etc/systemd/system/name@.service; enabled; vendor preset: enabled) Active: inactive (dead) (Result: exit-code) since Wed 2017-10-04 15:20:09 CEST; 3min 27s ago Process: 30116 ExecStop=/usr/bin/pkill --full %i (code=exited, status=1/FAILURE) Process: 30113 ExecStart=/usr/local/bin/binary -c /path/to/config/kkk.conf (code=exited, status=1/FA Main PID: 30113 (code=exited, status=1/FAILURE) Oct 04 15:20:08 host systemd: email@example.com: Unit entered failed state. Oct 04 15:20:08 host systemd: firstname.lastname@example.org: Failed with result 'exit-code'. Oct 04 15:20:09 host systemd: email@example.com: Service hold-off time over, scheduling restart. Oct 04 15:20:09 host systemd: Stopped my awesome service for kkk.
If I run systemctl --failed, I get
0 loaded units listed. Pass --all to see loaded but inactive units, too. To show all installed unit files use 'systemctl list-unit-files'.
which is obviously not correct, because the service is failed. Am I doing something wrong or missing something here? TIA.