Socket‑activated service stalls on upgrade: Type=simple vs Type=notify behavior
0 reputation · 08 Mar 2025, 17:56 UTC
0 reputation · 08 Mar 2025, 17:56 UTC
Migrate a small network service on Arch Linux without dropping existing connections by using systemd socket activation.
pacman -Syu.The choice between Type=simple (default) and Type=notify influences when systemd considers the service ready after a reload. With Type=simple the manager assumes readiness immediately, while Type=notify waits for the daemon to send a readiness notification.
Type=notify guarantee that new connections are routed to the upgraded process without interrupting existing ones?Type=simple for a socket‑activated service during a package upgrade?systemctl reload?34775 reputation · 09 Mar 2025, 05:00 UTC
To prevent stalls during an upgrade, use Type=notify. While Type=simple tells systemd the service is ready the moment the process forks, Type=notify forces the manager to wait for a readiness signal from the application. This ensures the new binary is fully initialized and listening on the inherited socket before systemd attempts to hand off new incoming connections to it.
The choice between these types determines how systemd manages the lifecycle of your service during a package upgrade or a restart:
accept(), leading to stalls or timeouts.READY=1 message via the DBUS socket. This is the safer choice for socket-activated services because it guarantees the process is capable of handling traffic before the transition is finalized.When pacman replaces a binary on Arch Linux, the running process remains in memory, holding the open file descriptor to the old code. To migrate without dropping existing connections:
systemctl restart creates a new instance using the updated binary.Type=simple, systemd might consider the new instance "active" immediately, but if the binary is still initializing, new connections hitting the socket buffer may be dropped or delayed.To verify that the new binary is actually serving traffic after an upgrade, use the following commands:
| Command | Purpose |
|---|---|
ls -l /proc/$(pid)/exe |
Confirms the running process is using the new binary path. |
ss -ltnp | grep : |
Shows which PID is currently actively listening on the socket. |
journalctl -u -f |
Checks for "Service ready" logs (if using Type=notify). |
Note: This analysis assumes your application supports the systemd notification protocol (e.g., via libsystemd). If the application does not support notifications, using Type=notify will cause the service to timeout.
Use comments to ask for clarification. Post a solution as an answer.
No question comments on this page.