Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to actually use this in a systemd setup? #4

Open
curvature opened this issue Sep 15, 2024 · 2 comments
Open

How to actually use this in a systemd setup? #4

curvature opened this issue Sep 15, 2024 · 2 comments

Comments

@curvature
Copy link

curvature commented Sep 15, 2024

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.

@cbranch
Copy link
Collaborator

cbranch commented Sep 17, 2024

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?

@curvature
Copy link
Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants