Implement UNIX sockets

Initial implementation done in https://gitlab.com/famedly/conduit/-/merge_requests/507,
*substantially* reworked, corrected, improved by infamous <ehuff007@gmail.com>,
and few parts done by me.

Co-authored-by: infamous <ehuff007@gmail.com>
Signed-off-by: girlbossceo <june@girlboss.ceo>
This commit is contained in:
girlbossceo 2023-07-29 21:57:41 +00:00
parent 3bfdae795d
commit 42efc9deaf
8 changed files with 186 additions and 40 deletions

View file

@ -379,9 +379,26 @@ impl Service {
&self.config.well_known_client
}
pub fn unix_socket_path(&self) -> &Option<PathBuf> {
&self.config.unix_socket_path
}
pub fn shutdown(&self) {
self.shutdown.store(true, atomic::Ordering::Relaxed);
// On shutdown
if self.unix_socket_path().is_some() {
match &self.unix_socket_path() {
Some(path) => {
std::fs::remove_file(path.to_owned()).unwrap();
}
None => error!(
"Unable to remove socket file at {:?} during shutdown.",
&self.unix_socket_path()
),
};
};
info!(target: "shutdown-sync", "Received shutdown notification, notifying sync helpers...");
services().globals.rotate.fire();
}