]> git.proxmox.com Git - proxmox-backup.git/blobdiff - proxmox-restore-daemon/src/main.rs
Set MMAP_THRESHOLD to a fixed value (128K)
[proxmox-backup.git] / proxmox-restore-daemon / src / main.rs
index 9cf7f75574771d7835c0d1551c26687ceef81e35..47790a7db86c814d2d22f2a7c11e4891e5c81e80 100644 (file)
@@ -13,12 +13,8 @@ use lazy_static::lazy_static;
 use log::{error, info};
 use tokio::sync::mpsc;
 use tokio_stream::wrappers::ReceiverStream;
-use http::request::Parts;
-use http::Response;
-use hyper::{Body, StatusCode};
-use hyper::header;
 
-use proxmox::api::RpcEnvironmentType;
+use proxmox_router::RpcEnvironmentType;
 
 use pbs_client::DEFAULT_VSOCK_PORT;
 use proxmox_rest_server::{ApiConfig, RestServer};
@@ -42,6 +38,8 @@ lazy_static! {
 
 /// This is expected to be run by 'proxmox-file-restore' within a mini-VM
 fn main() -> Result<(), Error> {
+    pbs_tools::setup_libc_malloc_opts();
+
     if !Path::new(VM_DETECT_FILE).exists() {
         bail!(
             "This binary is not supposed to be run manually, use 'proxmox-file-restore' instead."
@@ -50,7 +48,7 @@ fn main() -> Result<(), Error> {
 
     // don't have a real syslog (and no persistance), so use env_logger to print to a log file (via
     // stdout to a serial terminal attached by QEMU)
-    env_logger::from_env(env_logger::Env::default().default_filter_or("info"))
+    env_logger::Builder::from_env(env_logger::Env::default().default_filter_or("info"))
         .write_style(env_logger::WriteStyle::Never)
         .format_timestamp_millis()
         .init();
@@ -67,7 +65,7 @@ fn main() -> Result<(), Error> {
 
     info!("disk scan complete, starting main runtime...");
 
-    pbs_runtime::main(run())
+    proxmox_async::runtime::main(run())
 }
 
 /// ensure we have our /run dirs, system users and stuff like that setup
@@ -91,29 +89,14 @@ fn setup_system_env() -> Result<(), Error> {
     Ok(())
 }
 
-fn get_index(
-    _auth_id: Option<String>,
-    _language: Option<String>,
-    _api: &ApiConfig,
-    _parts: Parts,
-) -> Response<Body> {
-
-    let index = "<center><h1>Proxmox Backup Restore Daemon/h1></center>";
-
-    Response::builder()
-        .status(StatusCode::OK)
-        .header(header::CONTENT_TYPE, "text/html")
-        .body(index.into())
-        .unwrap()
-}
 
 async fn run() -> Result<(), Error> {
     watchdog_init();
 
-    let auth_config = Arc::new(
-        auth::ticket_auth().map_err(|err| format_err!("reading ticket file failed: {}", err))?,
-    );
-    let config = ApiConfig::new("", &ROUTER, RpcEnvironmentType::PUBLIC, auth_config, get_index)?;
+    let adaptor = StaticAuthAdapter::new()
+        .map_err(|err| format_err!("reading ticket file failed: {}", err))?;
+
+    let config = ApiConfig::new("", &ROUTER, RpcEnvironmentType::PUBLIC, adaptor)?;
     let rest_server = RestServer::new(config);
 
     let vsock_fd = get_vsock_fd()?;