0

I run a custom service with a classic init script on Debian Jessie. Debian Jessie uses systemd. The reason that I use an init script is that I also use the same service on Debian Wheezy, which does not have systemd.

Since the service may crash occasionally, I want it to be relaunched when it stops. My understanding is that systemd will take care of this. However, when I manually kill the service (without systemctl stop service), systemctl status will report the service as active (exited).

It is my understanding that this means that systemd simply considers the service to be one that can be "running" without having an process. The documentation mentions RemainAfterExit as a way to configure this behaviour, but this is a flag for use in a unit-file, I only have an init script.

Is there a way to let systemd know that an init service needs a process to be considered active? In other words, let it know that active (exited) is an undesired state?

-1

I solved the problem by writing a generic boilerplate systemd unit file. Store the file in /etc/systemd/system/$SERVICE.service.

Replace $SERVICE with the service name.

[Unit]
Description=$SERVICE init script wrapper
After=network.target

[Service]
ExecStart=/etc/init.d/$SERVICE start
ExecStop=/etc/init.d/$SERVICE stop
ExecReload=/etc/init.d/$SERVICE reload
PIDFile=/var/run/$SERVICE.pid
RemainAfterExit=no
Restart=always
Type=forking

[Install]
WantedBy=multiuser.target

Run systemctl daemon-reload to refresh systemd's internals.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.