move 'wait_for_local_worker' from client to server
this just made no sense in the client Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
This commit is contained in:
parent
0be8bce718
commit
72fbe9ffa5
|
@ -12,6 +12,7 @@ use proxmox_backup::tools;
|
||||||
use proxmox_backup::config;
|
use proxmox_backup::config;
|
||||||
use proxmox_backup::api2::{self, types::* };
|
use proxmox_backup::api2::{self, types::* };
|
||||||
use proxmox_backup::client::*;
|
use proxmox_backup::client::*;
|
||||||
|
use proxmox_backup::server::wait_for_local_worker;
|
||||||
|
|
||||||
mod proxmox_backup_manager;
|
mod proxmox_backup_manager;
|
||||||
use proxmox_backup_manager::*;
|
use proxmox_backup_manager::*;
|
||||||
|
|
|
@ -8,10 +8,10 @@ use anyhow::{bail, Error};
|
||||||
use pbs_datastore::{CryptConfig, CryptMode};
|
use pbs_datastore::{CryptConfig, CryptMode};
|
||||||
use pbs_datastore::data_blob::DataBlob;
|
use pbs_datastore::data_blob::DataBlob;
|
||||||
use pbs_datastore::read_chunk::ReadChunk;
|
use pbs_datastore::read_chunk::ReadChunk;
|
||||||
|
use pbs_datastore::read_chunk::AsyncReadChunk;
|
||||||
use pbs_runtime::block_on;
|
use pbs_runtime::block_on;
|
||||||
|
|
||||||
use super::BackupReader;
|
use super::BackupReader;
|
||||||
use crate::backup::AsyncReadChunk;
|
|
||||||
|
|
||||||
/// Read chunks from remote host using ``BackupReader``
|
/// Read chunks from remote host using ``BackupReader``
|
||||||
#[derive(Clone)]
|
#[derive(Clone)]
|
||||||
|
|
|
@ -10,7 +10,6 @@ use proxmox::api::cli::format_and_print_result;
|
||||||
use pbs_tools::percent_encoding::percent_encode_component;
|
use pbs_tools::percent_encoding::percent_encode_component;
|
||||||
|
|
||||||
use super::HttpClient;
|
use super::HttpClient;
|
||||||
use crate::server::{UPID, worker_is_active_local};
|
|
||||||
|
|
||||||
/// Display task log on console
|
/// Display task log on console
|
||||||
///
|
///
|
||||||
|
@ -116,23 +115,3 @@ pub async fn view_task_result(
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Wait for a locally spanned worker task
|
|
||||||
///
|
|
||||||
/// Note: local workers should print logs to stdout, so there is no
|
|
||||||
/// need to fetch/display logs. We just wait for the worker to finish.
|
|
||||||
pub async fn wait_for_local_worker(upid_str: &str) -> Result<(), Error> {
|
|
||||||
|
|
||||||
let upid: UPID = upid_str.parse()?;
|
|
||||||
|
|
||||||
let sleep_duration = core::time::Duration::new(0, 100_000_000);
|
|
||||||
|
|
||||||
loop {
|
|
||||||
if worker_is_active_local(&upid) {
|
|
||||||
tokio::time::sleep(sleep_duration).await;
|
|
||||||
} else {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Ok(())
|
|
||||||
}
|
|
||||||
|
|
|
@ -804,3 +804,23 @@ impl pbs_datastore::task::TaskState for WorkerTask {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Wait for a locally spanned worker task
|
||||||
|
///
|
||||||
|
/// Note: local workers should print logs to stdout, so there is no
|
||||||
|
/// need to fetch/display logs. We just wait for the worker to finish.
|
||||||
|
pub async fn wait_for_local_worker(upid_str: &str) -> Result<(), Error> {
|
||||||
|
|
||||||
|
let upid: UPID = upid_str.parse()?;
|
||||||
|
|
||||||
|
let sleep_duration = core::time::Duration::new(0, 100_000_000);
|
||||||
|
|
||||||
|
loop {
|
||||||
|
if worker_is_active_local(&upid) {
|
||||||
|
tokio::time::sleep(sleep_duration).await;
|
||||||
|
} else {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue