Skip to content

Commit

Permalink
cli: fix node shutdown (paritytech#100)
Browse files Browse the repository at this point in the history
  • Loading branch information
andresilva authored and rphmeier committed Jan 23, 2019
1 parent 3a88e24 commit e837443
Showing 1 changed file with 12 additions and 3 deletions.
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(())
}

0 comments on commit e837443

Please sign in to comment.