Definite's Extractor

My findings on Life, Linux, Open Source, and so on.

systemd: remember to keep the daemons alive

My sinopia daemon refused to start. After dig out the journal, I found that ExecStop run straight after ExecStart, what the…

After some research, I found that for daemons, or any other program that put themselves at the background, systemd thought they are stopped, thus stop the service for you. To prevent this, you need following in your systemd service file:

[Service]
...
RemainAfterExit=yes

so your daemons can live happily ever after.

The END

4 responses to “systemd: remember to keep the daemons alive

  1. Alexander 2016/08/09 at 4:40 pm

    Type=forking or simple will do the same job. RemainAfterExit needs to be done only for one time scripts with Type=oneshot (f.e. ntpdate).

    Like

    • dingyichen 2016/08/09 at 6:24 pm

      Not sure “Type=forking” is the “proper” way in my case.
      I use “make run” to launch the actual daemon (e.g. docker run -d), so it is weird to use forking as it does not call fork().

      According to man pages, RemainAfterExit does not need to associate to type oneshot.
      In fact, unless you are desperately need multiple ExecStart, it does not really make sense to call it “oneshot” if it is intended to stay.

      Like

  2. Pingback: systemd: remember to keep the daemons alive https://dingyichen.word… | Dr. Roy Schestowitz (罗伊)

  3. Pingback: Quickies: civilize systemd | 0ddn1x: tricks with *nix

Leave a comment