Why is systemd stopping service immediately after it is started?

Try changing Restart=on-abort to Restart=on-abnormal

From http://www.freedesktop.org/software/systemd/man/systemd.service.html:

Setting this to on-failure is the recommended choice for long-running services, in order to increase reliability by attempting automatic recovery from errors. For services that shall be able to terminate on their own choice (and avoid immediate restarting), on-abnormal is an alternative choice.

Also, you may want to add Type=oneshot to the [Service] section.

From https://wiki.archlinux.org/index.php/Systemd#Service_types:

Type=oneshot: this is useful for scripts that do a single job and then exit. You may want to set RemainAfterExit=yes as well so that systemd still considers the service as active after the process has exited.

You can paste my recommended changes below:

[Unit]
Description=Starts the DCCA index software

[Install]
WantedBy=multi-user.target

[Service]
Type=oneshot
ExecStart=/opt/insiteone/bin/indexControl start
ExecStop=/opt/insiteone/bin/indexControl stop
Restart=on-abnormal

Something else to consider is whether or not you even need the Restart= line ... Does the script this service file calls fail often?

Tags:

Linux

Systemd