Commit 9cb36130 authored by André Silva's avatar André Silva Committed by asynchronous rob
Browse files

cli: fix node shutdown (#100)

parent 5893fa7c
Pipeline #28944 passed with stages
in 12 minutes and 25 seconds
...@@ -115,8 +115,8 @@ pub fn run<I, T, W>(args: I, worker: W, version: cli::VersionInfo) -> error::Res ...@@ -115,8 +115,8 @@ pub fn run<I, T, W>(args: I, worker: W, version: cli::VersionInfo) -> error::Res
let mut runtime = Runtime::new()?; let mut runtime = Runtime::new()?;
let executor = runtime.executor(); let executor = runtime.executor();
match config.roles == service::Roles::LIGHT { match config.roles == service::Roles::LIGHT {
true => run_until_exit(&mut runtime, Factory::new_light(config, executor)?, worker)?, true => run_until_exit(runtime, Factory::new_light(config, executor)?, worker)?,
false => run_until_exit(&mut runtime, Factory::new_full(config, executor)?, worker)?, false => run_until_exit(runtime, Factory::new_full(config, executor)?, worker)?,
} }
} }
} }
...@@ -124,7 +124,7 @@ pub fn run<I, T, W>(args: I, worker: W, version: cli::VersionInfo) -> error::Res ...@@ -124,7 +124,7 @@ pub fn run<I, T, W>(args: I, worker: W, version: cli::VersionInfo) -> error::Res
} }
fn run_until_exit<T, C, W>( fn run_until_exit<T, C, W>(
runtime: &mut Runtime, mut runtime: Runtime,
service: T, service: T,
worker: W, worker: W,
) -> error::Result<()> ) -> error::Result<()>
...@@ -141,5 +141,14 @@ fn run_until_exit<T, C, W>( ...@@ -141,5 +141,14 @@ fn run_until_exit<T, C, W>(
let _ = runtime.block_on(worker.work(&*service)); let _ = runtime.block_on(worker.work(&*service));
exit_send.fire(); 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();
Ok(()) Ok(())
} }
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment