-
Notifications
You must be signed in to change notification settings - Fork 16
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
Notify the service state through sd_notify
#3903
Conversation
Deploying matrix-authentication-service-docs with Cloudflare Pages
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
SGTM otherwise, with the caveat that it'd be good to check all the logic works in practice if you haven't already
@@ -32,6 +33,7 @@ rand.workspace = true | |||
rand_chacha = "0.3.1" | |||
reqwest.workspace = true | |||
rustls.workspace = true | |||
sd-notify = "0.4.5" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
does this need to be gated behind a flag, or is it cross-platform enough not to be a problem?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It does use stuff from std::os::unix
, which is 'Unix-only'. We don't claim to support Windows, so I'm happy keeping it like that
if let Err(e) = sd_notify::notify(false, states) { | ||
tracing::error!( | ||
error = &e as &dyn std::error::Error, | ||
"Failed to notify service manager" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is this error expected if someone is not using systemd? If so, should we soften it somewhat so it doesn't sound like a major problem for them?
Maybe it would be good to elaborate in the comment what this is doing, I'm not sure most people would understand what this is for without having seen it before. (at least, I don't think knowledge about this is that common, but especially not amongst non-systemd users)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If NOTIFY_SOCKET
is not set, it returns Ok(())
and is basically a no-op
Actually, tokio doesn't like that we create an interval with a zero duration… so it crashed if the watchdog environment variables were not set. Fixed that in d57552c |
This does mainly two things:
The API of the
sd-notify
crate is… weird. I was tempted to implement myself, but the fact that we need to be able to callclock_gettime
withCLOCK_MONOTONIC
makes me prefer someone else having thatunsafe
code already written.Fixes #3879