-
-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Description
Submission type
- Request for enhancement (RFE)
It would be useful to introduce an option (e.g. RuntimeDirectoryPreserve) that preserves the contents of RuntimeDirectory directories when a service is being restarted as opposed to stopped:
[Service]
RuntimeDirectory=myservice
RuntimeDirectoryMode=0755
RuntimeDirectoryPreserve=restart
This option would have the following values:
never: Always delete the directories when the service is stopped (current behavior and default)always: Only ensure the directory is created. Never delete it.restart: Follow the same logic as clearing of the file descriptor store. That is, preserve the directories if the service is to be immediately restarted.
This will simplify using the file descriptor store in the way suggested by the sd_notify man page under FDSTORE=1:
This is useful for implementing service restart schemes where services serialize their state to /run, push their file descriptors to the system manager, and are then restarted, retrieving their state again via socket passing and /run.
Currently a service wishing to perform the above process cannot write its state file into a directory created by RuntimeDirectory. This is very inconvenient for unprivileged processes.
Further to this, ensuring the directory is deleted when a complete stop occurs ensures that serialized state is automatically removed at the appropriate moment. Without this it is necessary for the service to detect "cold" starts and ensure serialized state is ignored.