Skip to content
This repository was archived by the owner on Nov 15, 2023. It is now read-only.
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
cli: fix node shutdown
  • Loading branch information
andresilva committed Jan 22, 2019
commit fd7af9e3c045ecdd6fbc73f27b85d6e5763304a9
15 changes: 12 additions & 3 deletions cli/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -115,16 +115,16 @@ pub fn run<I, T, W>(args: I, worker: W, version: cli::VersionInfo) -> error::Res
let mut runtime = Runtime::new()?;
let executor = runtime.executor();
match config.roles == service::Roles::LIGHT {
true => run_until_exit(&mut runtime, Factory::new_light(config, executor)?, worker)?,
false => run_until_exit(&mut runtime, Factory::new_full(config, executor)?, worker)?,
true => run_until_exit(runtime, Factory::new_light(config, executor)?, worker)?,
false => run_until_exit(runtime, Factory::new_full(config, executor)?, worker)?,
}
}
}
Ok(())
}

fn run_until_exit<T, C, W>(
runtime: &mut Runtime,
mut runtime: Runtime,
service: T,
worker: W,
) -> error::Result<()>
Expand All @@ -141,5 +141,14 @@ fn run_until_exit<T, C, W>(

let _ = runtime.block_on(worker.work(&*service));
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(())
}