Move admin startup command exec later in init sequence. (closes #320)
Signed-off-by: Jason Volk <jason@zemos.net>
This commit is contained in:
@@ -21,6 +21,9 @@ pub(crate) async fn run(services: Arc<Services>) -> Result {
|
|||||||
// Install the admin room callback here for now
|
// Install the admin room callback here for now
|
||||||
tuwunel_admin::init(&services.admin).await;
|
tuwunel_admin::init(&services.admin).await;
|
||||||
|
|
||||||
|
// Execute configured startup commands.
|
||||||
|
services.admin.startup_execute().await?;
|
||||||
|
|
||||||
// Setup shutdown/signal handling
|
// Setup shutdown/signal handling
|
||||||
let handle = ServerHandle::new();
|
let handle = ServerHandle::new();
|
||||||
let sigs = server
|
let sigs = server
|
||||||
|
|||||||
@@ -1,8 +1,5 @@
|
|||||||
use ruma::events::room::message::RoomMessageEventContent;
|
use ruma::events::room::message::RoomMessageEventContent;
|
||||||
use tokio::{
|
use tokio::task::yield_now;
|
||||||
task::yield_now,
|
|
||||||
time::{Duration, sleep},
|
|
||||||
};
|
|
||||||
use tuwunel_core::{Err, Result, debug, debug_info, error, implement, info};
|
use tuwunel_core::{Err, Result, debug, debug_info, error, implement, info};
|
||||||
|
|
||||||
pub(super) const SIGNAL: &str = "SIGUSR2";
|
pub(super) const SIGNAL: &str = "SIGUSR2";
|
||||||
@@ -34,7 +31,7 @@ pub(super) async fn console_auto_stop(&self) {
|
|||||||
|
|
||||||
/// Execute admin commands after startup
|
/// Execute admin commands after startup
|
||||||
#[implement(super::Service)]
|
#[implement(super::Service)]
|
||||||
pub(crate) async fn startup_execute(&self) -> Result {
|
pub async fn startup_execute(&self) -> Result {
|
||||||
// List of commands to execute
|
// List of commands to execute
|
||||||
let commands = &self.services.server.config.admin_execute;
|
let commands = &self.services.server.config.admin_execute;
|
||||||
|
|
||||||
@@ -49,17 +46,6 @@ pub(crate) async fn startup_execute(&self) -> Result {
|
|||||||
.config
|
.config
|
||||||
.admin_execute_errors_ignore;
|
.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() {
|
for (i, command) in commands.iter().enumerate() {
|
||||||
if let Err(e) = self.execute_command(i, command.clone()).await
|
if let Err(e) = self.execute_command(i, command.clone()).await
|
||||||
&& !errors
|
&& !errors
|
||||||
|
|||||||
@@ -208,8 +208,6 @@ pub async fn start(self: &Arc<Self>) -> Result<Arc<Self>> {
|
|||||||
.start()
|
.start()
|
||||||
.await?;
|
.await?;
|
||||||
|
|
||||||
self.admin.startup_execute().await?;
|
|
||||||
|
|
||||||
debug_info!("Services startup complete.");
|
debug_info!("Services startup complete.");
|
||||||
|
|
||||||
Ok(Arc::clone(self))
|
Ok(Arc::clone(self))
|
||||||
|
|||||||
Reference in New Issue
Block a user