support reloading config via SIGUSR1

Signed-off-by: Jason Volk <jason@zemos.net>
This commit is contained in:
Jason Volk 2025-01-28 20:55:28 +00:00
parent a567e314e9
commit 2f449ba47d
7 changed files with 75 additions and 10 deletions

View file

@ -1,6 +1,6 @@
use std::{fmt::Write, path::PathBuf, sync::Arc};
use conduwuit::{info, utils::time, warn, Config, Err, Result};
use conduwuit::{info, utils::time, warn, Err, Result};
use ruma::events::room::message::RoomMessageEventContent;
use crate::admin_command;
@ -32,15 +32,8 @@ pub(super) async fn reload_config(
&self,
path: Option<PathBuf>,
) -> Result<RoomMessageEventContent> {
use conduwuit::config::check;
let path = path.as_deref().into_iter();
let new = Config::load(path).and_then(|raw| Config::new(&raw))?;
let old = &self.services.server.config;
check::reload(old, &new)?;
self.services.server.config.update(new)?;
self.services.config.reload(path)?;
Ok(RoomMessageEventContent::text_plain("Successfully reconfigured."))
}