-
Notifications
You must be signed in to change notification settings - Fork 18
/
Copy pathprocess.nix
133 lines (124 loc) · 3.23 KB
/
process.nix
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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
{ name, pkgs, lib, ... }:
let
inherit (lib) types mkOption;
probeType = types.submoduleWith {
specialArgs = { inherit lib; };
modules = [ ./probe.nix ];
};
in
{
options = {
command = import ./command.nix { inherit name pkgs lib; } {
description = ''
The command or script or package that runs this process
If a package is given, its executable is used as the command. Otherwise,
the command string is wrapped in a `pkgs.writeShellApplication` which
uses ShellCheck and runs the command in bash.
'';
};
depends_on = mkOption {
description = "Process dependency relationships";
type = types.nullOr (types.attrsOf (types.submodule {
options = {
condition = mkOption {
type = types.enum [
"process_completed"
"process_completed_successfully"
"process_healthy"
"process_started"
];
example = "process_healthy";
};
};
}));
default = null;
};
availability = {
restart = mkOption {
type = types.nullOr (types.enum [
"always"
"on_failure"
"exit_on_failure"
"no"
]);
default = null;
example = "on_failure";
};
exit_on_end = mkOption {
type = types.nullOr types.bool;
default = null;
example = true;
};
backoff_seconds = mkOption {
type = types.nullOr types.ints.unsigned;
default = null;
example = 2;
};
max_restarts = mkOption {
type = types.nullOr types.ints.unsigned;
default = null;
example = 0;
};
};
shutdown = {
command = mkOption {
type = types.nullOr types.str;
default = null;
example = "sleep 2 && pkill -f 'test_loop.bash my-proccess'";
};
signal = mkOption {
type = types.nullOr types.ints.unsigned;
default = null;
example = 15;
};
timeout_seconds = mkOption {
type = types.nullOr types.ints.unsigned;
default = null;
example = 10;
};
};
working_dir = mkOption {
type = types.nullOr types.str;
default = null;
example = "/tmp";
};
readiness_probe = mkOption {
type = types.nullOr probeType;
default = null;
};
liveness_probe = mkOption {
type = types.nullOr probeType;
default = null;
};
namespace = mkOption {
type = types.str;
default = "default";
};
environment = import ./environment.nix { inherit lib; };
log_location = mkOption {
type = types.nullOr types.str;
default = null;
example = "./pc.my-proccess.log";
};
disable_ansi_colors = mkOption {
type = types.nullOr types.bool;
default = null;
example = true;
};
is_daemon = mkOption {
type = types.nullOr types.bool;
default = null;
example = true;
};
is_foreground = mkOption {
type = types.nullOr types.bool;
default = null;
example = true;
};
disabled = mkOption {
type = types.nullOr types.bool;
default = if name == "test" then true else null;
example = true;
};
};
}