]>
git.proxmox.com Git - proxmox-backup.git/blob - src/server.rs
1 //! Proxmox Server/Service framework
3 //! This code provides basic primitives to build our REST API
4 //! services. We want async IO, so this is built on top of
7 use anyhow
::{format_err, Error}
;
8 use lazy_static
::lazy_static
;
11 use proxmox
::sys
::linux
::procfs
::PidStat
;
16 static ref PID
: i32 = unsafe { libc::getpid() }
;
17 static ref PSTART
: u64 = PidStat
::read_from_pid(Pid
::from_raw(*PID
)).unwrap().starttime
;
24 pub fn pstart() -> u64 {
28 pub fn write_pid(pid_fn
: &str) -> Result
<(), Error
> {
29 let pid_str
= format
!("{}\n", *PID
);
30 let opts
= proxmox
::tools
::fs
::CreateOptions
::new();
31 proxmox
::tools
::fs
::replace_file(pid_fn
, pid_str
.as_bytes(), opts
)
34 pub fn read_pid(pid_fn
: &str) -> Result
<i32, Error
> {
35 let pid
= proxmox
::tools
::fs
::file_get_contents(pid_fn
)?
;
36 let pid
= std
::str::from_utf8(&pid
)?
.trim();
37 pid
.parse().map_err(|err
| format_err
!("could not parse pid - {}", err
))
40 pub fn ctrl_sock_from_pid(pid
: i32) -> String
{
41 format
!("\0{}/control-{}.sock", buildcfg
::PROXMOX_BACKUP_RUN_DIR
, pid
)
44 pub fn our_ctrl_sock() -> String
{
45 ctrl_sock_from_pid(*PID
)
49 pub use environment
::*;
58 pub use command_socket
::*;
61 pub use worker_task
::*;
77 pub use verify_job
::*;
85 mod email_notifications
;
86 pub use email_notifications
::*;