Skip to content

[RFE] Allow preserving contents of RuntimeDirectory over process restart #6087

@marack

Description

@marack

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    RFE 🎁Request for Enhancement, i.e. a feature requestpid1

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions