systemd Restart=on-failure write deduplication on CentOS
0 reputation · 14 Sept 2024, 18:41 UTC
Goal
Restart a CentOS systemd service after failure using Restart=on-failure while ensuring writes completed before the crash are not repeated on restart.
Constraints
systemd restarts the process but does not record whether a write finished before termination. No standard unit hook tells a restarted process whether it is starting for the first time or resuming after failure. Idempotency therefore depends on application logic or external state files. Changing the restart policy requires root or sudo. CentOS 7 ships systemd 219 while CentOS Stream 9 ships systemd 252, and StartLimitIntervalSec semantics differ across releases.
Is there a supported systemd mechanism to indicate restart-after-failure to ExecStart without modifying the application?
Can unit-file options suppress duplicate non-idempotent writes after a crash, or must deduplication live entirely in the application or state layer?
Does the correct approach differ between CentOS 7 systemd 219 and CentOS Stream 9 systemd 252?