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))