-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsystemd.service.j2
127 lines (125 loc) · 3.98 KB
/
systemd.service.j2
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
[Unit]
Description={{ description }}
Wants=network.target
DefaultDependencies={{ unit_default_dependencies | default(true) }}
{%- if unit_on_failure %}
OnFailure={{ unit_on_failure }}
{%- endif %}
{#- For autogenerated services include stupid developer check here #}
ConditionUser={{ unit_condition_user }}
{%- if unit_on_success %}
OnSuccess={{ unit_on_success }}
{%- endif %}
{#- TODO: wants and requires could be repeated -- list input + loop #}
{%- if unit_wants %}
Wants={{ unit_wants }}
{%- endif %}
{%- if unit_requires %}
Requires={{ unit_requires }}
{%- endif %}
{#- If service has resource controlling in place require unit #}
{%- if service_slice %}
Requires={{ service_slice }}
{%- endif %}
{%- if unit_bindsto %}
BindsTo={{ unit_bindsto }}
{%- endif %}
{%- if unit_before %}
Before={{ unit_before }}
{%- endif %}
{%- if unit_after %}
After={{ unit_after }}
{%- endif %}
{%- if unit_success_action %}
SuccessAction={{ unit_success_action }}
{%- endif %}
{%- if unit_failure_action %}
FailureAction={{ unit_failure_action }}
{%- endif %}
{#- Conditions #}
{%- if unit_condition_path_exists %}
{#- Check for the existence of a file #}
ConditionPathExists={{ unit_condition_path_exists }}
{%- endif %}
{%- if unit_condition_path_exists_glob %}
{#- Checks for the existence of at least one file or directory matching
the specified globbing pattern #}
ConditionPathExistsGlob={{ unit_condition_path_exists_glob }}
{%- endif %}
{%- if unit_condition_path_is_directory %}
ConditionPathIsDirectory={{ unit_condition_path_is_directory }}
{%- endif %}
{%- if unit_condition_path_is_symbolic_link %}
ConditionPathIsSymbolicLink={{ unit_condition_path_is_symbolic_link }}
{%- endif %}
{%- if unit_condition_path_is_read_write %}
ConditionPathIsReadWrite={{ unit_condition_path_is_read_write }}
{%- endif %}
{%- if unit_condition_directory_not_empty %}
ConditionDirectoryNotEmpty={{ unit_condition_directory_not_empty }}
{%- endif %}
{%- if unit_condition_file_not_empty %}
ConditionFileNotEmpty={{ unit_condition_file_not_empty }}
{%- endif %}
{%- if unit_condition_file_is_executable %}
ConditionFileIsExecutable={{ unit_condition_file_is_executable }}
{%- endif %}
[Service]
Type={{ service_type | default("simple") }}
RemainAfterExit={{ service_remain_after_exit | default(false) }}
GuessMainPID={{ service_guess_main_pid | default(true) }}
{#- Main executable, invokes flat system command or carburator executor. #}
ExecStart={{ service_exec_start }}
EnvironmentFile={{ service_environment_file }}
{%- if service_slice %}
Slice={{ service_slice }}
{%- endif %}
{%- if service_exit_type and (not service_type or service_type != "oneshot") %}
ExitType={{ service_exit_type }}
{%- endif %}
{#- TODO: all supporting scripts could be repeated -- list input + loop #}
{%- if service_exec_start_pre %}
ExecStartPre={{ service_exec_start_pre }}
{%- endif %}
{%- if service_exec_start_post %}
ExecStartPost={{ service_exec_start_post }}
{%- endif %}
{%- if service_exec_condition %}
ExecCondition={{ service_exec_condition }}
{%- endif %}
{%- if service_exec_reload %}
ExecReload={{ service_exec_reload }}
{%- endif %}
{%- if service_exec_stop %}
ExecStop={{ service_exec_stop }}
{%- endif %}
{%- if service_exec_stop_post %}
ExecStopPost={{ service_exec_stop_post }}
{%- endif %}
{%- if not service_type or service_type != "oneshot" %}
{#- Systemd default for restart is 'no' but lets go wild here and set it
to 'always'. Default in our case is a long running process. #}
Restart={{ service_restart | default("always") }}
RestartSec={{ service_restart_wait | default(5) }}
{%- if service_runtime_max_sec %}
RuntimeMaxSec={{ service_runtime_max_sec }}
{%- endif %}
{%- endif %}
{%- if service_user %}
User={{ service_user }}
{%- endif %}
{%- if service_group %}
Group={{ service_group }}
{%- endif %}
{%- if not is_template %}
[Install]
{%- if install_wanted_by %}
WantedBy={{ install_wanted_by }}
{%- endif %}
{%- if install_required_by %}
RequiredBy={{ install_required_by }}
{%- endif %}
{%- if install_upheld_by %}
UpheldBy={{ install_upheld_by }}
{%- endif %}
{%- endif %}