1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
|
// config.reef — TOML service definition parser
//
// Parses /etc/zyginit.d/*.toml service definitions into ServiceDef structs.
// Uses Reef's built-in TOML parser: import encoding.toml
//
// This module should be implemented first — it has no illumos dependencies
// and can be tested on any platform.
import encoding.toml
import io.fs
// Service types
enum ServiceType {
Daemon, // long-running process, restarted on exit
Oneshot, // runs once, considered "started" after exit 0
Transient, // runs once, not tracked after exit
}
// Restart policy
enum RestartPolicy {
Always,
OnFailure,
Never,
}
// Stop method
enum StopMethod {
Contract, // signal all processes in contract (default)
Exec, // run a stop command
}
// Service definition — parsed from TOML
struct ServiceDef {
name: String,
description: String,
service_type: ServiceType,
// exec
start_cmd: String,
stop_cmd: Option<String>,
// stop
stop_method: StopMethod,
stop_signal: String, // "TERM", "HUP", etc.
stop_timeout: i32, // seconds
// dependencies
requires: Vec<String>, // hard dependencies — must be running
after: Vec<String>, // ordering — start after these, but don't require
// contract
contract_param: Vec<String>,
contract_fatal: Vec<String>,
// restart
restart_policy: RestartPolicy,
restart_delay: i32, // seconds
max_retries: i32, // -1 = unlimited
}
// Parse a single TOML file into a ServiceDef
fn parse_service(path: String) -> Result<ServiceDef, String> {
// TODO: implement
// 1. Read file contents
// 2. Parse TOML
// 3. Extract fields with defaults
// 4. Validate required fields
Err("not yet implemented")
}
// Scan /etc/zyginit.d/enabled.d/ and return list of enabled service paths
fn scan_enabled(config_dir: String) -> Result<Vec<String>, String> {
// TODO: implement
// 1. Read symlinks in enabled.d/
// 2. Resolve each to its .toml file
// 3. Return list of absolute paths
Err("not yet implemented")
}
// Load all enabled services
fn load_enabled_services(config_dir: String) -> Result<Vec<ServiceDef>, String> {
// TODO: implement
// 1. scan_enabled()
// 2. parse_service() for each
// 3. Return Vec of ServiceDefs
Err("not yet implemented")
}
|