zipplet / godaemon

Powerful daemoniser with nagios monitoring for Linux
MIT License
2 stars 0 forks source link

Custom handlers #3

Open Gilbert142 opened 7 years ago

Gilbert142 commented 7 years ago

Whenever the daemon has been restarted (and the email sent), make it so the user can config other handlers. Such as executing bash scripts, starting other services, etc.

zipplet commented 7 years ago

Would it be sufficient if the custom handler stdout/stderr was logged in the godaemon log (or do you want that in a seperate log), and do you need support for the handler to be run setuid//setgid in a sandbox?

The current design will cause a custom handler to block the restart of the task while the handler runs (like the current email handler does). That might be OK for your use case though - let me know. However if your custom handler takes a long time to do whatever it needs to do it will cause a delay in restarting the task.

Making it support simultaneous execution of a custom handler like another program while simultaneously restarting the task would mean extending godaemon to support running + monitoring multiple tasks simultaneously from a single process - which is not too difficult but much more work than simply running the custom handler, waiting for it to finish then restarting the task.

If that's not needed for now I can have godaemon kill the custom handler (with a log as appropriate) if it blocks for too long due to a mistake/bug in custom handler (configurable timeout).

The current email handler does that - it kills itself if it fails to transmit the email within 10 seconds.

Gilbert142 commented 7 years ago

I think logging in the godaemon log would be fine, obviously with a prefix that makes it clear it's the handler's output. I don't think the handler needs to run in a sandbox, it will most likely just be a simple bash script/node script.

In my case just killing the custom handler in 20 seconds or so would serve my purpose fine. Sync would be nice, but isn't really required at this point.

zipplet commented 7 years ago

Got it - I'll open another issue once this one is closed for making asynchronous tasks possible, but add simple synchronous support for the moment. Thanks!