mirror of
https://git.proxmox.com/git/proxmox-backup-qemu
synced 2025-10-04 20:49:26 +00:00
use new get_runtime_with_builder
This commit is contained in:
parent
8fc4b1f92d
commit
b364baf8ff
@ -18,7 +18,7 @@ cbindgen = "0.14.2"
|
|||||||
libc = "0.2"
|
libc = "0.2"
|
||||||
bytes = "0.5"
|
bytes = "0.5"
|
||||||
proxmox = { version = "0.1.42", features = [ "sortable-macro", "api-macro" ] }
|
proxmox = { version = "0.1.42", features = [ "sortable-macro", "api-macro" ] }
|
||||||
proxmox-backup = { git = "git://git.proxmox.com/git/proxmox-backup.git", tag = "v0.7.0" }
|
proxmox-backup = { git = "git://git.proxmox.com/git/proxmox-backup.git", tag = "v0.8.0" }
|
||||||
#proxmox-backup = { path = "../proxmox-backup" }
|
#proxmox-backup = { path = "../proxmox-backup" }
|
||||||
chrono = "0.4" # Date and time library for Rust
|
chrono = "0.4" # Date and time library for Rust
|
||||||
anyhow = "1.0"
|
anyhow = "1.0"
|
||||||
|
@ -5,7 +5,9 @@ use once_cell::sync::OnceCell;
|
|||||||
use std::os::raw::c_int;
|
use std::os::raw::c_int;
|
||||||
|
|
||||||
use futures::future::{Future, Either, FutureExt};
|
use futures::future::{Future, Either, FutureExt};
|
||||||
|
use tokio::runtime::Runtime;
|
||||||
|
|
||||||
|
use proxmox_backup::tools::runtime::get_runtime_with_builder;
|
||||||
use proxmox_backup::backup::{CryptConfig, BackupManifest, load_and_decrypt_key};
|
use proxmox_backup::backup::{CryptConfig, BackupManifest, load_and_decrypt_key};
|
||||||
use proxmox_backup::client::{HttpClient, HttpClientOptions, BackupWriter};
|
use proxmox_backup::client::{HttpClient, HttpClientOptions, BackupWriter};
|
||||||
|
|
||||||
@ -16,7 +18,7 @@ use crate::commands::*;
|
|||||||
|
|
||||||
pub(crate) struct BackupTask {
|
pub(crate) struct BackupTask {
|
||||||
setup: BackupSetup,
|
setup: BackupSetup,
|
||||||
runtime: tokio::runtime::Runtime,
|
runtime: Arc<Runtime>,
|
||||||
crypt_config: Option<Arc<CryptConfig>>,
|
crypt_config: Option<Arc<CryptConfig>>,
|
||||||
writer: OnceCell<Arc<BackupWriter>>,
|
writer: OnceCell<Arc<BackupWriter>>,
|
||||||
last_manifest: OnceCell<Arc<BackupManifest>>,
|
last_manifest: OnceCell<Arc<BackupManifest>>,
|
||||||
@ -28,16 +30,11 @@ pub(crate) struct BackupTask {
|
|||||||
|
|
||||||
impl BackupTask {
|
impl BackupTask {
|
||||||
|
|
||||||
pub fn new(setup: BackupSetup) -> Result<Self, Error> {
|
/// Create a new instance, using the specified Runtime
|
||||||
|
///
|
||||||
let mut builder = tokio::runtime::Builder::new();
|
/// We keep a reference to the runtime - else the runtime can be
|
||||||
builder.threaded_scheduler();
|
/// dropped and further connections fails.
|
||||||
builder.enable_all();
|
pub fn with_runtime(setup: BackupSetup, runtime: Arc<Runtime>) -> Result<Self, Error> {
|
||||||
builder.max_threads(6);
|
|
||||||
builder.core_threads(4);
|
|
||||||
builder.thread_name("proxmox-backup-qemu-worker");
|
|
||||||
|
|
||||||
let runtime = builder.build()?;
|
|
||||||
|
|
||||||
let crypt_config = match setup.keyfile {
|
let crypt_config = match setup.keyfile {
|
||||||
None => None,
|
None => None,
|
||||||
@ -62,6 +59,19 @@ impl BackupTask {
|
|||||||
aborted: OnceCell::new() })
|
aborted: OnceCell::new() })
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn new(setup: BackupSetup) -> Result<Self, Error> {
|
||||||
|
let runtime = get_runtime_with_builder(|| {
|
||||||
|
let mut builder = tokio::runtime::Builder::new();
|
||||||
|
builder.threaded_scheduler();
|
||||||
|
builder.enable_all();
|
||||||
|
builder.max_threads(6);
|
||||||
|
builder.core_threads(4);
|
||||||
|
builder.thread_name("proxmox-backup-worker");
|
||||||
|
builder
|
||||||
|
});
|
||||||
|
Self::with_runtime(setup, runtime)
|
||||||
|
}
|
||||||
|
|
||||||
pub fn runtime(&self) -> tokio::runtime::Handle {
|
pub fn runtime(&self) -> tokio::runtime::Handle {
|
||||||
self.runtime.handle().clone()
|
self.runtime.handle().clone()
|
||||||
}
|
}
|
||||||
|
@ -7,7 +7,7 @@ use anyhow::{format_err, bail, Error};
|
|||||||
use once_cell::sync::OnceCell;
|
use once_cell::sync::OnceCell;
|
||||||
use tokio::runtime::Runtime;
|
use tokio::runtime::Runtime;
|
||||||
|
|
||||||
use proxmox_backup::tools::runtime::{get_runtime, block_in_place};
|
use proxmox_backup::tools::runtime::{get_runtime_with_builder, block_in_place};
|
||||||
use proxmox_backup::backup::*;
|
use proxmox_backup::backup::*;
|
||||||
use proxmox_backup::client::{HttpClient, HttpClientOptions, BackupReader, RemoteChunkReader};
|
use proxmox_backup::client::{HttpClient, HttpClientOptions, BackupReader, RemoteChunkReader};
|
||||||
|
|
||||||
@ -64,7 +64,15 @@ impl RestoreTask {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn new(setup: BackupSetup) -> Result<Self, Error> {
|
pub fn new(setup: BackupSetup) -> Result<Self, Error> {
|
||||||
let runtime = get_runtime();
|
let runtime = get_runtime_with_builder(|| {
|
||||||
|
let mut builder = tokio::runtime::Builder::new();
|
||||||
|
builder.threaded_scheduler();
|
||||||
|
builder.enable_all();
|
||||||
|
builder.max_threads(6);
|
||||||
|
builder.core_threads(4);
|
||||||
|
builder.thread_name("proxmox-restore-worker");
|
||||||
|
builder
|
||||||
|
});
|
||||||
Self::with_runtime(setup, runtime)
|
Self::with_runtime(setup, runtime)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user