start lobby manager after installation
This commit is contained in:
parent
7391b990aa
commit
27f9cf738c
2 changed files with 29 additions and 12 deletions
|
|
@ -43,7 +43,7 @@ pub struct LeagueAppState {
|
|||
pub database: Database,
|
||||
|
||||
/// separate thread that handles reporting to lobby
|
||||
pub lobby_mgr: LobbyMgr,
|
||||
pub lobby_mgr: Option<LobbyMgr>,
|
||||
|
||||
// /// separate thread that manages all the server slots
|
||||
// pub slot_mgr: SlotMgr,
|
||||
|
|
@ -104,15 +104,6 @@ impl LeagueAppState {
|
|||
},
|
||||
};
|
||||
|
||||
// setup lobby manager
|
||||
let lobby_mgr = match LobbyMgr::new(shutdown_control.clone(), &config, league_logo_local.clone()) {
|
||||
Ok(lobby_mgr) => lobby_mgr,
|
||||
Err(e) => {
|
||||
log::error!("Failed to start lobby manager!");
|
||||
return Err(e);
|
||||
}
|
||||
};
|
||||
|
||||
// compile app state
|
||||
let mut app_state = Self {
|
||||
// slot_mgr,
|
||||
|
|
@ -122,7 +113,7 @@ impl LeagueAppState {
|
|||
database,
|
||||
league_logo_http,
|
||||
league_logo_local,
|
||||
lobby_mgr,
|
||||
lobby_mgr: None,
|
||||
};
|
||||
|
||||
Ok(SsloAppState::new(
|
||||
|
|
@ -131,6 +122,27 @@ impl LeagueAppState {
|
|||
))
|
||||
}
|
||||
|
||||
/// This is must be called after new(),
|
||||
/// intention is to allow the installer to execute before the background workers start
|
||||
pub async fn start(&mut self) -> Result<(), SsloError> {
|
||||
|
||||
// start lobby manager
|
||||
if self.lobby_mgr.is_some() {
|
||||
log::error!("lobby_mgr was already started!");
|
||||
return Err(SsloError::PropagateAlreadyLoggedError());
|
||||
} else {
|
||||
self.lobby_mgr = match LobbyMgr::new(self.shutdown_control.clone(), &self.config, self.league_logo_local.clone()) {
|
||||
Ok(lobby_mgr) => Some(lobby_mgr),
|
||||
Err(e) => {
|
||||
log::error!("Failed to start lobby manager!");
|
||||
return Err(e);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
|
||||
/// Relate a path to the sslo database directory and return.
|
||||
/// When the given path already absolute, it is returned unchanged.
|
||||
|
|
@ -163,7 +175,10 @@ impl LeagueAppState {
|
|||
}
|
||||
|
||||
pub fn join(&self) {
|
||||
self.lobby_mgr.join();
|
||||
if let Some(lobby_mgr) = self.lobby_mgr.as_ref() {
|
||||
lobby_mgr.join();
|
||||
}
|
||||
|
||||
// self.slot_mgr.join();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -49,6 +49,8 @@ async fn main() -> Result<(), SsloError> {
|
|||
log::info!("installation successfully finished within: {}", formatter.format(duration_end - duration_start));
|
||||
}
|
||||
|
||||
// startup everything
|
||||
app_state.substate_mut().start().await?;
|
||||
|
||||
// setup https routing
|
||||
let axum_router = http::create_router(app_state.clone());
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue