From be733857587e8e0577be028bfe2fb727892d9304 Mon Sep 17 00:00:00 2001 From: Gregor Reitzenstein Date: Wed, 16 Dec 2020 12:24:19 +0100 Subject: [PATCH] Properly start api server --- src/main.rs | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/src/main.rs b/src/main.rs index 5c279b2..8960b76 100644 --- a/src/main.rs +++ b/src/main.rs @@ -168,15 +168,17 @@ fn maybe(matches: clap::ArgMatches, log: Arc) -> Result<(), Error> { } let (signal, shutdown) = async_channel::bounded::<()>(1); - easy_parallel::Parallel::new() + let (_, r) = easy_parallel::Parallel::new() .each(0..4, |_| smol::block_on(ex.run(shutdown.recv()))) - .run(); + .finish(|| { + let db = db::Databases::new(&log, &config)?; + // TODO: Spawn api connections on their own (non-main) thread, use the main thread to + // handle signals (a cli if stdin is not closed?) and make it stop and clean up all threads + // when bffh should exit + server::serve_api_connections(log.clone(), config, db, network) + // Signal is dropped here, stopping all executor threads as well. + }); - let db = db::Databases::new(&log, &config)?; - // TODO: Spawn api connections on their own (non-main) thread, use the main thread to - // handle signals (a cli if stdin is not closed?) and make it stop and clean up all threads - // when bffh should exit - server::serve_api_connections(log.clone(), config, db, network) - // Signal is dropped here, stopping all executor threads as well. + return r; } }