Delay opening browser and spawing local workers

Creating the server might take quite a while if a fetch url is
configured and no local repo is found. During this time the web server
is not yet running, so the browser link and local workers would fail to
connect and just show/log errors.
This commit is contained in:
Joscha 2023-08-17 18:58:05 +02:00
parent 4f2b0a0b88
commit 238ce5e463

View file

@ -167,16 +167,19 @@ async fn run() -> somehow::Result<()> {
match args.command {
Command::Server(command) => {
info!("Starting server");
let open = command.open;
let local_worker = command.local_worker;
if command.open {
let (server, recurring_rx) = Server::new(&config.server, command).await?;
if open {
tokio::task::spawn(open_in_browser(&config.server));
}
if command.local_worker > 0 {
tokio::task::spawn(launch_local_workers(config, command.local_worker));
if local_worker > 0 {
tokio::task::spawn(launch_local_workers(config, local_worker));
}
let (server, recurring_rx) = Server::new(&config.server, command).await?;
select! {
_ = wait_for_signal() => {}
_ = server.run(recurring_rx) => {}