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

Daemonize #9

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open

Daemonize #9

wants to merge 5 commits into from

Conversation

kirichkov
Copy link
Owner

This makes the script into a proper daemon, that by default forks and runs in the background.

I've also added handling for command line options. A peculiarity is that if you run the systemd script and you want to see the debug log you should change the ExecStart line to include the -v (verbose) option

@kirichkov
Copy link
Owner Author

kirichkov commented May 2, 2017

Can you hold off merging this? I want to also add the option for the script to drop down privileges if it's run as root.

Nevermind. It makes little sense to implement this. One has to just fix where the location of the PID file should be.

@kamaradclimber
Copy link
Collaborator

Thanks again for your PR @kirichkov.

I don't think I'll merge this in its actual form. Adding this feature increases the size of the code to handle something that most init system I know can do.
I'm sure you can handle a non-forking binary with initv, upstart and systemd.

Patch to add command line option parsing is interesting though, would you be able to separate it from the rest?

@kirichkov
Copy link
Owner Author

To be honest I have not experimented with systemd but can it actually write down a PID file? I did not find such an option, hence - fork, write PID file.

@kamaradclimber
Copy link
Collaborator

Most init system can manage process staying in the foreground, not requiring any pid file.

For which type of system would you need this feature?

@kirichkov
Copy link
Owner Author

I use this for monit - it's a lot more reliable when you have a pid file than using it's process matching feature. And I use monit to make sure no process hangs - e.g. hass once in a while hangs and starts using 100% but on a single core, which is not noticable unless you run top, because it's not total 100% usage, but the process is still hung, and I've set monit to restart it if monit consumes more than 20% continuously for 10 minutes.

Monit also helps me abstract managing processes and I can just ignore whether it's a systemV, upstart or systemd underneath.

@kirichkov
Copy link
Owner Author

I don't mind removing the forking while keeping the pid file creation. Or I can reverse, i.e. fork, if a command line switch is present and by default run it non-forking.

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

Successfully merging this pull request may close these issues.

2 participants