executing the dummy cmd in async context

This commit is contained in:
Jędrzej Stuczyński
2023-10-31 17:34:03 +00:00
parent 52b8703028
commit a6c627df33
7 changed files with 38 additions and 10 deletions
Generated
+1
View File
@@ -7603,6 +7603,7 @@ dependencies = [
"lazy_static",
"nix 0.27.1",
"nym-bin-common",
"tokio",
]
[[package]]
+1
View File
@@ -15,5 +15,6 @@ anyhow = { workspace = true }
clap = { workspace = true, features = ["derive"] }
lazy_static = { workspace = true }
nix = "0.27.1"
tokio = { workspace = true, features = ["rt", "macros", "signal", "process"] }
nym-bin-common = { path = "../../common/bin-common", features = ["output_format"] }
+4 -1
View File
@@ -1,9 +1,12 @@
// Copyright 2023 - Nym Technologies SA <contact@nymtech.net>
// SPDX-License-Identifier: Apache-2.0
use nym_bin_common::output_format::OutputFormat;
#[derive(clap::Args, Debug)]
pub(crate) struct Args {
//
#[clap(short, long, default_value_t = OutputFormat::default())]
output: OutputFormat,
}
pub(crate) fn execute(args: Args) -> anyhow::Result<()> {
+4 -1
View File
@@ -1,9 +1,12 @@
// Copyright 2023 - Nym Technologies SA <contact@nymtech.net>
// SPDX-License-Identifier: Apache-2.0
use nym_bin_common::output_format::OutputFormat;
#[derive(clap::Args, Debug)]
pub(crate) struct Args {
//
#[clap(short, long, default_value_t = OutputFormat::default())]
output: OutputFormat,
}
pub(crate) fn execute(args: Args) -> anyhow::Result<()> {
+4 -1
View File
@@ -1,9 +1,12 @@
// Copyright 2023 - Nym Technologies SA <contact@nymtech.net>
// SPDX-License-Identifier: Apache-2.0
use nym_bin_common::output_format::OutputFormat;
#[derive(clap::Args, Debug)]
pub(crate) struct Args {
//
#[clap(short, long, default_value_t = OutputFormat::default())]
output: OutputFormat,
}
pub(crate) fn execute(args: Args) -> anyhow::Result<()> {
+9
View File
@@ -43,9 +43,18 @@ impl Cli {
#[derive(Subcommand, Debug)]
pub(crate) enum Commands {
/// TODO: document the command
Init(init::Args),
/// TODO: document the command
Run(run::Args),
/// TODO: document the command
BuildInfo(build_info::Args),
/// TODO: document the command
AddUpgrade(add_upgrade::Args),
/// TODO: document the command
Config(config::Args),
}
+15 -7
View File
@@ -1,6 +1,8 @@
// Copyright 2023 - Nym Technologies SA <contact@nymtech.net>
// SPDX-License-Identifier: Apache-2.0
use tokio::runtime;
#[derive(clap::Args, Debug)]
pub(crate) struct Args {
#[clap(trailing_var_arg = true)]
@@ -9,14 +11,20 @@ pub(crate) struct Args {
}
pub(crate) fn execute(args: Args) -> anyhow::Result<()> {
println!("run");
// TODO: experiment with the minimal runtime
let rt = runtime::Builder::new_current_thread().enable_io().build()?;
let mut child = std::process::Command::new("echo")
.args(args.daemon_args)
.spawn()?;
// spawn the root task
rt.block_on(async {
println!("run");
let status = child.wait()?;
let mut child = tokio::process::Command::new("echo")
.args(args.daemon_args)
.spawn()?;
println!("{:?}", status);
Ok(())
let status = child.wait().await?;
println!("{:?}", status);
Ok(())
})
}