rehash: 'echoircd rehash' CLI + SIGHUP reload the running config in place via a pidfile
This commit is contained in:
parent
42fe82556b
commit
a7ae0d86a9
4 changed files with 96 additions and 3 deletions
21
src/ircd.rs
21
src/ircd.rs
|
|
@ -101,6 +101,8 @@ pub enum Event {
|
|||
},
|
||||
/// Background timer tick — drives ping/idle timeouts.
|
||||
Tick,
|
||||
/// Re-read the config file and apply it live (from SIGHUP / the `rehash` CLI).
|
||||
Rehash,
|
||||
}
|
||||
|
||||
/// Insert an extra IRCv3 tag into a wire line's tag block, creating the `@…`
|
||||
|
|
@ -323,6 +325,7 @@ impl Ircd {
|
|||
let _ = reply.send(resp);
|
||||
}
|
||||
Event::Tick => self.on_tick(),
|
||||
Event::Rehash => self.on_rehash(),
|
||||
}
|
||||
self.drain_hooks();
|
||||
}
|
||||
|
|
@ -643,6 +646,24 @@ impl Ircd {
|
|||
|
||||
/// Background timer: PING idle clients, reap the unresponsive and the
|
||||
/// never-registered.
|
||||
/// SIGHUP / `rehash` CLI: re-read the config and apply it live, keeping the
|
||||
/// running config if the file can't be read (same policy as /REHASH).
|
||||
fn on_rehash(&mut self) {
|
||||
let path = self.server.conf_path.clone();
|
||||
eprintln!("rehashing server config file.");
|
||||
match Config::try_load(&path) {
|
||||
Some(fresh) => {
|
||||
self.server.announce("The server is rehashing its configuration.");
|
||||
self.server.apply_config(fresh);
|
||||
self.server.announce("Server configuration reloaded.");
|
||||
eprintln!("server configuration is reloaded.");
|
||||
}
|
||||
None => {
|
||||
eprintln!("rehash: could not read {path} — the running configuration was kept.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn on_tick(&mut self) {
|
||||
self.server.ping_links(); // keepalive on every server link
|
||||
self.server.purge_xlines(); // drop expired server bans
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue