all lists on lists.proxmox.com
 help / color / mirror / Atom feed
From: Dietmar Maurer <dietmar@proxmox.com>
To: pbs-devel@lists.proxmox.com
Subject: [pbs-devel] [PATCH proxmox-backup 6/6] proxmox-backup-manager: setup worker and command socket
Date: Thu, 23 Sep 2021 12:13:29 +0200	[thread overview]
Message-ID: <20210923101329.950146-6-dietmar@proxmox.com> (raw)
In-Reply-To: <20210923101329.950146-1-dietmar@proxmox.com>

---
 src/bin/proxmox-backup-manager.rs | 22 ++++++++++++++++++----
 1 file changed, 18 insertions(+), 4 deletions(-)

diff --git a/src/bin/proxmox-backup-manager.rs b/src/bin/proxmox-backup-manager.rs
index b9e4e2ff..a03e1db8 100644
--- a/src/bin/proxmox-backup-manager.rs
+++ b/src/bin/proxmox-backup-manager.rs
@@ -5,6 +5,7 @@ use anyhow::{format_err, Error};
 use serde_json::{json, Value};
 
 use proxmox::api::{api, cli::*, RpcEnvironment};
+use proxmox::tools::fs::CreateOptions;
 
 use pbs_client::{connect_to_localhost, display_task_log, view_task_result};
 use pbs_tools::percent_encoding::percent_encode_component;
@@ -359,9 +360,7 @@ async fn get_versions(verbose: bool, param: Value) -> Result<Value, Error> {
     Ok(Value::Null)
 }
 
-fn main() {
-
-    proxmox_backup::tools::setup_safe_path_env();
+async fn run() -> Result<(), Error> {
 
     let cmd_def = CliCommandMap::new()
         .insert("acl", acl_commands())
@@ -401,12 +400,27 @@ fn main() {
             CliCommand::new(&API_METHOD_GET_VERSIONS)
         );
 
+    let backup_user = pbs_config::backup_user()?;
+    let file_opts = CreateOptions::new().owner(backup_user.uid).group(backup_user.gid);
+    proxmox_rest_server::init_worker_tasks(pbs_buildcfg::PROXMOX_BACKUP_LOG_DIR_M!().into(), file_opts.clone())?;
 
+    let mut commando_sock = proxmox_rest_server::CommandoSocket::new(proxmox_rest_server::our_ctrl_sock(), backup_user.gid);
+    proxmox_rest_server::register_task_control_commands(&mut commando_sock)?;
+    commando_sock.spawn()?;
 
     let mut rpcenv = CliEnvironment::new();
     rpcenv.set_auth_id(Some(String::from("root@pam")));
 
-   pbs_runtime::main(run_async_cli_command(cmd_def, rpcenv));
+    run_async_cli_command(cmd_def, rpcenv).await; // this call exit(-1) on error
+
+    Ok(())
+}
+
+fn main() -> Result<(), Error> {
+
+    proxmox_backup::tools::setup_safe_path_env();
+
+    pbs_runtime::main(run())
 }
 
 // shell completion helper
-- 
2.30.2





  parent reply	other threads:[~2021-09-23 10:13 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-09-23 10:13 [pbs-devel] [PATCH proxmox-backup 1/6] src/server/worker_task.rs: Avoid using pbs-api-type::Authid Dietmar Maurer
2021-09-23 10:13 ` [pbs-devel] [PATCH proxmox-backup 2/6] worker task: allow to configure path and owner/group Dietmar Maurer
2021-09-23 11:36   ` Fabian Grünbichler
2021-09-23 10:13 ` [pbs-devel] [PATCH proxmox-backup 3/6] use UPID and systemd helpers from proxmox 0.13.4 Dietmar Maurer
2021-09-23 10:13 ` [pbs-devel] [PATCH proxmox-backup 4/6] move worker_task.rs into proxmox-rest-server crate Dietmar Maurer
2021-09-23 10:13 ` [pbs-devel] [PATCH proxmox-backup 5/6] proxmox-daily-update: setup worker and command socket Dietmar Maurer
2021-09-23 10:13 ` Dietmar Maurer [this message]
2021-09-23 13:20 ` [pbs-devel] [PATCH proxmox-backup 1/6] src/server/worker_task.rs: Avoid using pbs-api-type::Authid Fabian Grünbichler

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210923101329.950146-6-dietmar@proxmox.com \
    --to=dietmar@proxmox.com \
    --cc=pbs-devel@lists.proxmox.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal