Reload TLS config on SIGHUP

This commit is contained in:
Lambda 2024-09-26 16:29:03 -07:00 committed by Charles Hall
parent 39880cc6ac
commit 94d523ebcb
No known key found for this signature in database
GPG key ID: 7B8E0645816E07CF
4 changed files with 78 additions and 15 deletions

View file

@ -44,6 +44,7 @@ fn version() -> String {
#[derive(Debug, Clone, Copy)]
enum ApplicationState {
Ready,
Reloading,
Stopping,
}
@ -61,6 +62,21 @@ fn set_application_state(state: ApplicationState) {
match state {
ApplicationState::Ready => notify(&[NotifyState::Ready]),
ApplicationState::Reloading => {
let timespec = nix::time::clock_gettime(
nix::time::ClockId::CLOCK_MONOTONIC,
)
.expect("CLOCK_MONOTONIC should be usable");
let monotonic_usec =
timespec.tv_sec() * 1_000_000 + timespec.tv_nsec() / 1000;
notify(&[
NotifyState::Reloading,
NotifyState::Custom(&format!(
"MONOTONIC_USEC={monotonic_usec}",
)),
]);
}
ApplicationState::Stopping => notify(&[NotifyState::Stopping]),
};
}