Add PID file support#1733
Conversation
| fmt.Fprintf(f, "%d\n", os.Getpid()) | ||
| f.Close() | ||
| defer func() { | ||
| err := os.Remove(cfg.PIDFile) |
There was a problem hiding this comment.
Sorry, I have a stupid question to ask.
Why delete the PIDFile?
There was a problem hiding this comment.
Most servers are expected to delete their PID file when the server shuts down — for example, Apache removes its PID file when shutting down.
However, since snapteld calls os.Exit() when it shuts down, I recently realized that this deferred function will not be executed, since os.Exit shuts down immediately without calling deferred functions.
There was a problem hiding this comment.
@cce
Thanks for your explanation!
Yes, I think the the actual behavior is not your meaning.
Could you please update this PR according your design when you are free?
|
@katarzyna-z I think it is better to handle the PID file in the service script, but not in snapteld. |
Fixes #878 by allowing for systemd, init scripts, etc, to be able to better manage snapteld and send it kill or restart signals.
Summary of changes:
--pid-fileflag andpid_fileconfig file option to snapteldTesting done:
@intelsdi-x/snap-maintainers