diff --git a/polkadot/cli/src/lib.rs b/polkadot/cli/src/lib.rs index 3052020cd9..ea3e01a16e 100644 --- a/polkadot/cli/src/lib.rs +++ b/polkadot/cli/src/lib.rs @@ -112,7 +112,7 @@ fn run_until_exit( worker: W, ) -> error::Result<()> where - T: Deref>, + T: Deref> + Future + Send + 'static, C: service::Components, BareService: PolkadotService, W: Worker, @@ -123,16 +123,13 @@ fn run_until_exit( let informant = cli::informant::build(&service); executor.spawn(exit.until(informant).map(|_| ())); - let _ = runtime.block_on(worker.work(&*service, Arc::new(executor))); - exit_send.fire(); - // we eagerly drop the service so that the internal exit future is fired, // but we need to keep holding a reference to the global telemetry guard let _telemetry = service.telemetry(); - drop(service); - // TODO [andre]: timeout this future (https://github.com/paritytech/substrate/issues/1318) - let _ = runtime.shutdown_on_idle().wait(); + let work = worker.work(&*service, Arc::new(executor)); + let _ = runtime.block_on(service.select(work)); + exit_send.fire(); Ok(()) }