From 3f06d6fbbd50c08d81c90a686df911e5beb39820 Mon Sep 17 00:00:00 2001 From: Dietmar Maurer Date: Tue, 21 Jan 2020 11:34:45 +0100 Subject: [PATCH] use proxmox_backup::tools::runtime::main to run async run_cli_command --- Cargo.toml | 2 +- src/bin/proxmox-backup-client.rs | 22 +++++++--------------- src/bin/proxmox-backup-manager.rs | 2 +- src/bin/pxar.rs | 2 +- 4 files changed, 10 insertions(+), 18 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 8962cc9d..f343091f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -29,7 +29,7 @@ pam = "0.7" pam-sys = "0.5" percent-encoding = "2.1" pin-utils = "0.1.0-alpha" -proxmox = { version = "0.1.4", features = [ "sortable-macro", "api-macro" ] } +proxmox = { version = "0.1.5", features = [ "sortable-macro", "api-macro" ] } #proxmox = { git = "ssh://gitolite3@proxdev.maurer-it.com/rust/proxmox", version = "0.1.2", features = [ "sortable-macro", "api-macro" ] } #proxmox = { path = "../proxmox/proxmox", features = [ "sortable-macro", "api-macro" ] } regex = "1.2" diff --git a/src/bin/proxmox-backup-client.rs b/src/bin/proxmox-backup-client.rs index 94c46144..a73c3c8d 100644 --- a/src/bin/proxmox-backup-client.rs +++ b/src/bin/proxmox-backup-client.rs @@ -1484,7 +1484,7 @@ async fn try_get(repo: &BackupRepository, url: &str) -> Value { } fn complete_backup_group(_arg: &str, param: &HashMap) -> Vec { - async_main(async { complete_backup_group_do(param).await }) + proxmox_backup::tools::runtime::main(async { complete_backup_group_do(param).await }) } async fn complete_backup_group_do(param: &HashMap) -> Vec { @@ -1514,7 +1514,7 @@ async fn complete_backup_group_do(param: &HashMap) -> Vec) -> Vec { - async_main(async { complete_group_or_snapshot_do(arg, param).await }) + proxmox_backup::tools::runtime::main(async { complete_group_or_snapshot_do(arg, param).await }) } async fn complete_group_or_snapshot_do(arg: &str, param: &HashMap) -> Vec { @@ -1533,7 +1533,7 @@ async fn complete_group_or_snapshot_do(arg: &str, param: &HashMap) -> Vec { - async_main(async { complete_backup_snapshot_do(param).await }) + proxmox_backup::tools::runtime::main(async { complete_backup_snapshot_do(param).await }) } async fn complete_backup_snapshot_do(param: &HashMap) -> Vec { @@ -1564,7 +1564,7 @@ async fn complete_backup_snapshot_do(param: &HashMap) -> Vec) -> Vec { - async_main(async { complete_server_file_name_do(param).await }) + proxmox_backup::tools::runtime::main(async { complete_server_file_name_do(param).await }) } async fn complete_server_file_name_do(param: &HashMap) -> Vec { @@ -1890,7 +1890,7 @@ fn mount( if verbose { // This will stay in foreground with debug output enabled as None is // passed for the RawFd. - return async_main(mount_do(param, None)); + return proxmox_backup::tools::runtime::main(mount_do(param, None)); } // Process should be deamonized. @@ -1906,7 +1906,7 @@ fn mount( Ok(ForkResult::Child) => { nix::unistd::close(pipe.0).unwrap(); nix::unistd::setsid().unwrap(); - async_main(mount_do(param, Some(pipe.1))) + proxmox_backup::tools::runtime::main(mount_do(param, Some(pipe.1))) } Err(_) => bail!("failed to daemonize process"), } @@ -2361,13 +2361,5 @@ fn main() { .insert("catalog", catalog_mgmt_cli()) .insert("task", task_mgmt_cli()); - run_cli_command(cmd_def); -} - -fn async_main(fut: F) -> ::Output { - let mut rt = tokio::runtime::Runtime::new().unwrap(); - let ret = rt.block_on(fut); - // This does not exist anymore. We need to actually stop our runaways instead... - // rt.shutdown_now(); - ret + proxmox_backup::tools::runtime::main(run_cli_command(cmd_def)); } diff --git a/src/bin/proxmox-backup-manager.rs b/src/bin/proxmox-backup-manager.rs index 21ac8228..c076e667 100644 --- a/src/bin/proxmox-backup-manager.rs +++ b/src/bin/proxmox-backup-manager.rs @@ -459,7 +459,7 @@ fn main() { .completion_cb("remote-store", complete_remote_datastore_name) ); - run_cli_command(cmd_def); + proxmox_backup::tools::runtime::main(run_cli_command(cmd_def)); } // shell completion helper diff --git a/src/bin/pxar.rs b/src/bin/pxar.rs index a05f94d4..a5b5e682 100644 --- a/src/bin/pxar.rs +++ b/src/bin/pxar.rs @@ -519,5 +519,5 @@ fn main() { .completion_cb("archive", tools::complete_file_name) ); - run_cli_command(cmd_def); + proxmox_backup::tools::runtime::main(run_cli_command(cmd_def)); }