shellflip icon indicating copy to clipboard operation
shellflip copied to clipboard

How to actually use this in a systemd setup?

Open curvature opened this issue 1 year ago • 2 comments

The example in the repo shows how to gracefully restart a standalone executable. In the case of systemd managed services, how can one make the spawned child process to be managed by systemd? The child process creation is encapsulated in the library(the Command::spawn call) and as far as I know this kind of child processes are not directly managed by systemd, meaning when the parent process eventually exits, the systemd will think the service is down and try to restart it, disregarding the child process.

Not a Linux expert myself but I do want to use this in my Rust project. Any help is greatly appreciated.

curvature avatar Sep 15 '24 11:09 curvature

systemd will think the service is down and try to restart it

In our experience, systemd will manage a forked process as the main PID once the previous main process terminates. What unit settings are you using where you observe this behaviour?

cbranch avatar Sep 17 '24 18:09 cbranch

systemd will think the service is down and try to restart it

In our experience, systemd will manage a forked process as the main PID once the previous main process terminates. What unit settings are you using where you observe this behaviour?

Initially I observed this behavior on Debian 12 with a usual service unit, later I learned from tableflip that I need to add a line PIDFile=/path/to/pid-file to the service section. It then worked for my golang project with tableflip. I'm still adapting my Rust project for shellfilp, in the meantime I found out that shellflip is sending notifications on the Unix socket with path reading from env var NOTIFY_SOCKET. Does this mean I should setup the service unit with type notify? I previously always use simple type(for tableflip as well), which might be the reason the issue arises in the first place?

Thanks for your help.

curvature avatar Sep 18 '24 01:09 curvature