diff --git a/src/main.rs b/src/main.rs index 8960b76..3e768cc 100644 --- a/src/main.rs +++ b/src/main.rs @@ -175,8 +175,11 @@ fn maybe(matches: clap::ArgMatches, log: Arc) -> Result<(), Error> { // 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 r = server::serve_api_connections(log.clone(), config, db, network); + + signal.try_send(()); + std::mem::drop(signal); + return r; }); return r; diff --git a/src/server.rs b/src/server.rs index 252b1a8..8e14ad9 100644 --- a/src/server.rs +++ b/src/server.rs @@ -54,6 +54,7 @@ pub fn serve_api_connections(log: Arc, config: Settings, db: Databases, .map(|l| { let addr = l.address.clone(); let port = l.port.unwrap_or(config::DEFAULT_PORT); + info!(&log, "Binding to {} port {}.", l.address.as_str(), &port); TcpListener::bind((l.address.as_str(), port)) // If the bind errors, include the address so we can log it // Since this closure is lazy we need to have a cloned addr @@ -124,6 +125,8 @@ pub fn serve_api_connections(log: Arc, config: Settings, db: Databases, return LoopResult::Continue; }); + info!(&log, "Started"); + // Check each signal as it arrives let handle_signals = signal.map(|r| { r.unwrap() }).into_stream();