diff --git a/substrate/bin/node-template/node/src/command.rs b/substrate/bin/node-template/node/src/command.rs index 2efca03837..ac950b5048 100644 --- a/substrate/bin/node-template/node/src/command.rs +++ b/substrate/bin/node-template/node/src/command.rs @@ -126,9 +126,11 @@ pub fn run() -> sc_cli::Result<()> { }, None => { let runner = cli.create_runner(&cli.run)?; - runner.run_node_until_exit(|config| match config.role { - Role::Light => service::new_light(config), - _ => service::new_full(config), + runner.run_node_until_exit(|config| async move { + match config.role { + Role::Light => service::new_light(config), + _ => service::new_full(config), + } }) } } diff --git a/substrate/bin/node/cli/src/command.rs b/substrate/bin/node/cli/src/command.rs index 7b84ff5a05..139c257722 100644 --- a/substrate/bin/node/cli/src/command.rs +++ b/substrate/bin/node/cli/src/command.rs @@ -72,9 +72,11 @@ pub fn run() -> Result<()> { match &cli.subcommand { None => { let runner = cli.create_runner(&cli.run)?; - runner.run_node_until_exit(|config| match config.role { - Role::Light => service::new_light(config), - _ => service::new_full(config), + runner.run_node_until_exit(|config| async move { + match config.role { + Role::Light => service::new_light(config), + _ => service::new_full(config), + } }) } Some(Subcommand::Inspect(cmd)) => { diff --git a/substrate/client/cli/src/runner.rs b/substrate/client/cli/src/runner.rs index 36b400daf9..e6d35282ad 100644 --- a/substrate/client/cli/src/runner.rs +++ b/substrate/client/cli/src/runner.rs @@ -172,24 +172,24 @@ impl Runner { /// A helper function that runs a node with tokio and stops if the process receives the signal /// `SIGTERM` or `SIGINT`. - pub fn run_node_until_exit( + pub fn run_node_until_exit>>( mut self, - initialise: impl FnOnce(Configuration) -> sc_service::error::Result, + initialize: impl FnOnce(Configuration) -> F, ) -> Result<()> { self.print_node_infos(); - let mut task_manager = initialise(self.config)?; + let mut task_manager = self.tokio_runtime.block_on(initialize(self.config))?; let res = self.tokio_runtime.block_on(main(task_manager.future().fuse())); self.tokio_runtime.block_on(task_manager.clean_shutdown()); res.map_err(|e| e.to_string().into()) } - /// A helper function that runs a command with the configuration of this node + /// A helper function that runs a command with the configuration of this node. pub fn sync_run(self, runner: impl FnOnce(Configuration) -> Result<()>) -> Result<()> { runner(self.config) } /// A helper function that runs a future with tokio and stops if the process receives - /// the signal SIGTERM or SIGINT + /// the signal `SIGTERM` or `SIGINT`. pub fn async_run( self, runner: impl FnOnce(Configuration) -> Result<(FUT, TaskManager)>, ) -> Result<()>