[systemd-devel] howto handle one time shutdown programs

Colin Guthrie colin at mageia.org
Fri Jun 26 06:28:58 PDT 2015


Andreas Buschmann wrote on 25/06/15 15:57:
> Hello,
> 
> I am writing a systemd .service file to handle NVDIMMs.
> 
> - start
> - stop
> - reload
> all work
> 
> The problem child is "restart".
> Restart is internally implemented as stop followed by start.
> 
> The problem is, that stop calls a program which does something to the
> NVDIMM hardware.
> After that no further access to the NVDIMMs is possible before the next
> reboot of the server.
> 
> How should I handle that sort of logic with systemd?

You can't.

Restart is always a stop and start again.

You can, however, implement a reload as you've already done. This is the
defined mechanism to tell a given daemon (or subsystem - whatever) to
maintain it's state but reload itself.

In order to prevent bad things happening when users manually stop your
unit, you may want to look into the RefuseManualStop= directive (man
systemd.unit) which will prevent your unit being stopped except
indirectly via dependencies. Typically this would only be when the user
reboots.

You would then want to make sure that anything that really does want a
stateful reload uses the reload action.

HTHs

Col


-- 

Colin Guthrie
colin(at)mageia.org
http://colin.guthr.ie/

Day Job:
  Tribalogic Limited http://www.tribalogic.net/
Open Source:
  Mageia Contributor http://www.mageia.org/
  PulseAudio Hacker http://www.pulseaudio.org/
  Trac Hacker http://trac.edgewall.org/


More information about the systemd-devel mailing list