TECHNOLOGY

Create serving runtime directories with an explicit lifetime

In this article
THE QUICK TAKE

Assign runtime directories an explicit service or tmpfiles lifecycle and separate transient coordination from durable artifacts.

A serving socket directory exists after a manual setup, then disappears after reboot or remains with stale ownership after a restart. Directory creation needs a lifecycle owner. Choose between service-bound runtime state and separately managed file rules instead of relying on a one-time shell command whose persistence was never defined.

Classify the directory’s contents

Separate transient sockets and PID-related state from persistent model artifacts, cache and accepted results. A runtime path is not a durable artifact repository. Record who writes each item and when a reader may depend on it. A single directory containing both transient coordination and irreplaceable output cannot be cleaned safely by a vague temporary-file rule.

Use service-bound lifetime deliberately

RuntimeDirectory creates a manager-owned directory associated with the unit’s execution configuration. Inspect user, group, mode and the supported preservation behavior across stops and restarts. A preserved runtime directory still does not become persistent across a reboot of the volatile runtime filesystem. Read the actual lifecycle rather than inferring durability from a directory that happened to survive one restart.

Separate tmpfiles rules

tmpfiles configuration defines creation and cleanup operations when the corresponding tool or units run. Those operations are not automatically identical to the model service’s start and stop. Rule type and age have documented meanings. Inspect ordering and invocation before relying on a boot-created path to exist for a later manually started service or an age rule to clean only inactive data.

Keep one clear owner

Avoid competing rules that recreate, chown or remove the same active path under different assumptions. Account for the service’s mount namespace and sandbox view; the host path’s existence alone may not show what the model sees. Broadly writable permissions are not a remedy for unclear identity or lifecycle ownership and can leave stale sockets available to unintended writers.

Verify stop, restart and boot assumptions

In a disposable unit, observe directory identity, permissions and contents through startup, stop and restart, then test the separately defined boot or cleanup fixture. Acceptance means each path has an explicit creation and removal contract. It does not validate artifact integrity, provide a storage capacity guarantee or establish that any file under a runtime-looking name is safe to delete.

Primary references

systemd Execution Environment.

systemd Temporary File Lifecycle.

Temporary File Rules.

Related reading: Read-only container will not start: where to allow temporary and cache writes; Reproducible inference stacks: preserving a GPU pilot’s result.

Earn rental income from GPUs

Have idle GPUs or looking to fund AI infrastructure? Retrivium finds a rental platform, sets up the server and helps you assess income and costs with a pilot.

Explore GPU hosting
← All articles