mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-13 04:41:02 +00:00
handle exit and avoid threads hanging (#137)
* barrier on starting network * handle exit better * give consensus service its own internal exit signal * update comment * remove stop_notifications and fix build
This commit is contained in:
committed by
Arkadiy Paronyan
parent
e253a4cb9f
commit
b6132800b7
@@ -68,6 +68,15 @@ pub fn run<I, T>(args: I) -> error::Result<()> where
|
||||
T: Into<std::ffi::OsString> + Clone,
|
||||
{
|
||||
let mut core = reactor::Core::new().expect("tokio::Core could not be created");
|
||||
let exit = {
|
||||
// can't use signal directly here because CtrlC takes only `Fn`.
|
||||
let (exit_send, exit) = mpsc::channel(1);
|
||||
ctrlc::CtrlC::set_handler(move || {
|
||||
exit_send.clone().send(()).wait().expect("Error sending exit notification");
|
||||
});
|
||||
|
||||
exit
|
||||
};
|
||||
|
||||
let yaml = load_yaml!("./cli.yml");
|
||||
let matches = match clap::App::from_yaml(yaml).version(crate_version!()).get_matches_from_safe(args) {
|
||||
@@ -140,11 +149,6 @@ pub fn run<I, T>(args: I) -> error::Result<()> where
|
||||
|
||||
informant::start(&service, core.handle());
|
||||
|
||||
let (exit_send, exit) = mpsc::channel(1);
|
||||
ctrlc::CtrlC::set_handler(move || {
|
||||
exit_send.clone().send(()).wait().expect("Error sending exit notification");
|
||||
});
|
||||
|
||||
let _rpc_servers = {
|
||||
let http_address = parse_address("127.0.0.1:9933", "rpc-port", &matches)?;
|
||||
let ws_address = parse_address("127.0.0.1:9944", "ws-port", &matches)?;
|
||||
|
||||
Reference in New Issue
Block a user