From 7e21b9d7304b412aa9de99ce357e132678c62130 Mon Sep 17 00:00:00 2001 From: Jason Volk Date: Thu, 12 Mar 2026 09:05:28 +0000 Subject: [PATCH] Move admin startup command exec later in init sequence. (closes #320) Signed-off-by: Jason Volk --- src/router/run.rs | 3 +++ src/service/admin/execute.rs | 18 ++---------------- src/service/services.rs | 2 -- 3 files changed, 5 insertions(+), 18 deletions(-) diff --git a/src/router/run.rs b/src/router/run.rs index 0141f6ee..b56c21fa 100644 --- a/src/router/run.rs +++ b/src/router/run.rs @@ -21,6 +21,9 @@ pub(crate) async fn run(services: Arc) -> Result { // Install the admin room callback here for now tuwunel_admin::init(&services.admin).await; + // Execute configured startup commands. + services.admin.startup_execute().await?; + // Setup shutdown/signal handling let handle = ServerHandle::new(); let sigs = server diff --git a/src/service/admin/execute.rs b/src/service/admin/execute.rs index 1f7ba2e3..99ee1bc7 100644 --- a/src/service/admin/execute.rs +++ b/src/service/admin/execute.rs @@ -1,8 +1,5 @@ use ruma::events::room::message::RoomMessageEventContent; -use tokio::{ - task::yield_now, - time::{Duration, sleep}, -}; +use tokio::task::yield_now; use tuwunel_core::{Err, Result, debug, debug_info, error, implement, info}; pub(super) const SIGNAL: &str = "SIGUSR2"; @@ -34,7 +31,7 @@ pub(super) async fn console_auto_stop(&self) { /// Execute admin commands after startup #[implement(super::Service)] -pub(crate) async fn startup_execute(&self) -> Result { +pub async fn startup_execute(&self) -> Result { // List of commands to execute let commands = &self.services.server.config.admin_execute; @@ -49,17 +46,6 @@ pub(crate) async fn startup_execute(&self) -> Result { .config .admin_execute_errors_ignore; - if !commands.is_empty() { - for i in 0..20 { - if self.handle.read().await.is_some() { - break; - } - - debug!(?i, "Waiting for admin module to load for startup commands..."); - sleep(Duration::from_millis(250)).await; - } - } - for (i, command) in commands.iter().enumerate() { if let Err(e) = self.execute_command(i, command.clone()).await && !errors diff --git a/src/service/services.rs b/src/service/services.rs index 2c32e357..7ccd9caa 100644 --- a/src/service/services.rs +++ b/src/service/services.rs @@ -208,8 +208,6 @@ pub async fn start(self: &Arc) -> Result> { .start() .await?; - self.admin.startup_execute().await?; - debug_info!("Services startup complete."); Ok(Arc::clone(self))