Skip to content

Add support for systemd watchdog protocol - #1562

Closed
mscherer wants to merge 1 commit into
redis:unstablefrom
mscherer:systemd_watchdog
Closed

mscherer wants to merge 1 commit into
redis:unstablefrom
mscherer:systemd_watchdog

Conversation

@mscherer

Copy link
Copy Markdown

Systemd use a regular message on a socket to see if a process is alive,
and restart it if needed. In order to achieve that, a timer is added to
the main loop to notify systemd that we are still alive. This doesn't
add any overhead on a non-systemd enabled system, and requires to be
configured by the sysadmin, in the systemd unit file to be used.
See http://0pointer.de/blog/projects/watchdog.html for details.

This requires a version newer than 209, due to usage of sd_watchdog_enabled
function, and require to pass HAVE_SYSTEMD=1 to the Makefile.

Systemd use a regular message on a socket to see if a process is alive,
and restart it if needed. In order to achieve that, a timer is added to
the main loop to notify systemd that we are still alive. This doesn't
add any overhead on a non-systemd enabled system, and requires to be
configured by the sysadmin, in the systemd unit file to be used.
See http://0pointer.de/blog/projects/watchdog.html for details.

This requires a version newer than 209, due to usage of sd_watchdog_enabled
function, and require to pass HAVE_SYSTEMD=1 to the Makefile.
@CameronNemo

Copy link
Copy Markdown

How is this any different from systemd just seeing if a process is running? Does systemd restart the service if there is a time lapse without the ALIVE=1 message?

@mscherer

Copy link
Copy Markdown
Author

The process can be running, but stuck in a loop or some other conditions making it running, but not working. So systemd would not see the process is blocked, while it see it is running ( because the process is not dead ).

And yes, systemd restart the service if there is no message.

@mattsta

mattsta commented Apr 16, 2014

Copy link
Copy Markdown
Contributor

Eeek. So, systemd requires external applications support its own internal design? Does systemd have the option of checking services using service-specific interfaces (redis-cli PING, like monit would)?

@mscherer

Copy link
Copy Markdown
Author

Nope, i do not think, even if that could be a feature to add. Redis and systemd work fine without the proposed patch, this is just a more integrated way of watching over the process.

@CameronNemo

Copy link
Copy Markdown

@mscherer He was talking about just for watchdog support. Yes, this is more integrated. No, that is not a positive. Matt's suggestion is actually a really good one that will allow for these features to extend to other monitoring tools and init systems with little effort, and require zero or near zero additions on the part of the daemon.

@mattsta You may have luck proposing / asking about the feature on the systemd ML. I am optimistic that they would be happy to have a method to get watchdog support without having to patch a thousand+ daemons :)

@mscherer

Copy link
Copy Markdown
Author

@CameronNemo
Having to run a external process to check every daemon would not really scale well on systemd side, as nagios have demonstrated in the past. It would work fine for 1 single daemon, but not if you plan to host a lot more ( think containers on a PaaS like openshift, for example, or any hosters ), or if you want to check in a very small interval.

And it would produce useless logs or load to the daemon for nothing, depending on the daemon ( for example, a TLS/SSL connexion that would need to be negotiated on every connexion ). Such job is also already done by external monitoring system, and the goal is not to reinvent the wheel, but provides some choices and a middle ground between "fully checking everything" ( as nagios/etc do ) and "just using wait to see the process is not working" ( like what upstart and systemd are doing without patches ).

@badboy badboy closed this Jul 15, 2017
sundb pushed a commit to sundb/redis that referenced this pull request Jul 28, 2025
Minor cleanup, fast path reduces the number of lines of code
and improves readability.

Signed-off-by: Nadav Levanoni <[email protected]>
Co-authored-by: Nadav Levanoni <[email protected]>
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.

4 participants