feature/ci-debian
rs 69 lines 1.91 KB
Raw
1 pub mod runner;
2 pub mod store;
3
4 use chrono::{DateTime, Utc};
5 use serde::{Deserialize, Serialize};
6 use std::{collections::HashMap, path::PathBuf};
7
8 /// Lifecycle state of a managed process.
9 #[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
10 #[serde(rename_all = "lowercase")]
11 pub enum ProcessStatus {
12 /// Process is alive and being monitored.
13 Running,
14 /// Process was deliberately stopped by the user.
15 Stopped,
16 /// Process crashed and exhausted its restart budget.
17 Errored,
18 }
19
20 impl std::fmt::Display for ProcessStatus {
21 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
22 match self {
23 Self::Running => write!(f, "online"),
24 Self::Stopped => write!(f, "stopped"),
25 Self::Errored => write!(f, "errored"),
26 }
27 }
28 }
29
30 /// A single managed process entry.
31 #[derive(Debug, Clone, Serialize, Deserialize)]
32 pub struct Process {
33 /// Monotonically increasing ID assigned by the daemon.
34 pub id: u32,
35
36 /// Human-readable name (must be unique).
37 pub name: String,
38
39 /// OS PID of the currently running process instance.
40 /// 0 when the process is stopped or not yet started.
41 pub pid: u32,
42
43 /// Shell command passed verbatim to `sh -c`.
44 pub command: String,
45
46 /// Working directory for the process.
47 pub cwd: PathBuf,
48
49 /// Extra environment variables merged on top of the daemon's env.
50 pub env: HashMap<String, String>,
51
52 /// Current lifecycle status.
53 pub status: ProcessStatus,
54
55 /// Total number of automatic restarts since the process was created.
56 pub restarts: u32,
57
58 /// Maximum automatic restarts before marking as errored (0 = unlimited).
59 pub max_restarts: u32,
60
61 /// Timestamp of the most recent spawn.
62 pub started_at: DateTime<Utc>,
63
64 /// Absolute path to the stdout log file.
65 pub log_out: PathBuf,
66
67 /// Absolute path to the stderr log file.
68 pub log_err: PathBuf,
69 }