don't panic if readline lib fails to initialize

fixes startup crash on non-standard TTYs
This commit is contained in:
xeon 2024-07-25 12:36:22 +03:00
parent 99123a15ef
commit a7da14c109

View file

@ -25,9 +25,9 @@ pub struct ServerState {
async fn main() -> Result<(), Box<dyn Error>> { async fn main() -> Result<(), Box<dyn Error>> {
splash::print("GameServer"); splash::print("GameServer");
let (rl, out) = Readline::new(String::from(">> ")).unwrap(); let rl = Readline::new(String::from(">> ")).ok();
init_tracing(rl.as_ref().map(|(_, out)| out.clone()));
init_tracing(Some(out.clone()));
tracing::info!("don't forget to visit https://discord.xeondev.com/"); tracing::info!("don't forget to visit https://discord.xeondev.com/");
let config = load_or_create_config::<NapGSConfig>("nap_gameserver.toml"); let config = load_or_create_config::<NapGSConfig>("nap_gameserver.toml");
@ -44,7 +44,10 @@ async fn main() -> Result<(), Box<dyn Error>> {
}); });
let command_mgr = CommandManager::new(state.clone()); let command_mgr = CommandManager::new(state.clone());
tokio::spawn(async move { command_mgr.run(rl, out).await });
if let Some((rl, out)) = rl {
tokio::spawn(async move { command_mgr.run(rl, out).await });
}
net::listen(state).await net::listen(state).await
} }