]> git.proxmox.com Git - proxmox-backup.git/blob - src/server.rs
aa4b57ec6417fadbeef82732723075b9d96986e8
[proxmox-backup.git] / src / server.rs
1 //! Proxmox Server/Service framework
2 //!
3 //! This code provides basic primitives to build our REST API
4 //! services. We want async IO, so this is built on top of
5 //! tokio/hyper.
6
7 use lazy_static::lazy_static;
8 use nix::unistd::Pid;
9
10 use proxmox::sys::linux::procfs::PidStat;
11
12 use crate::buildcfg;
13
14 lazy_static! {
15 static ref PID: i32 = unsafe { libc::getpid() };
16 static ref PSTART: u64 = PidStat::read_from_pid(Pid::from_raw(*PID)).unwrap().starttime;
17 }
18
19 pub fn pid() -> i32 {
20 *PID
21 }
22
23 pub fn pstart() -> u64 {
24 *PSTART
25 }
26
27 pub fn ctrl_sock_from_pid(pid: i32) -> String {
28 format!("\0{}/control-{}.sock", buildcfg::PROXMOX_BACKUP_RUN_DIR, pid)
29 }
30
31 pub fn our_ctrl_sock() -> String {
32 ctrl_sock_from_pid(*PID)
33 }
34
35 mod environment;
36 pub use environment::*;
37
38 mod upid;
39 pub use upid::*;
40
41 mod state;
42 pub use state::*;
43
44 mod command_socket;
45 pub use command_socket::*;
46
47 mod worker_task;
48 pub use worker_task::*;
49
50 mod h2service;
51 pub use h2service::*;
52
53 pub mod config;
54 pub use config::*;
55
56 pub mod formatter;
57
58 #[macro_use]
59 pub mod rest;
60
61 pub mod jobstate;
62
63 mod verify_job;
64 pub use verify_job::*;
65
66 mod prune_job;
67 pub use prune_job::*;
68
69 mod gc_job;
70 pub use gc_job::*;
71
72 mod email_notifications;
73 pub use email_notifications::*;