forked from kardianos/service
-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathservice_upstart_linux.tmpl
37 lines (28 loc) · 951 Bytes
/
service_upstart_linux.tmpl
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
# {{ .Description }}
{{ with .DisplayName }}description "{{ . }}"{{ end }}
{{ if .HasKillStanza }}kill signal INT{{ end }}
{{ with .ChRoot }}chroot {{ . }}{{ end }}
{{ with .WorkingDirectory }}chdir {{ . }}{{ end }}
start on filesystem or runlevel [2345]
stop on runlevel [!2345]
{{ if and .UserName .HasSetUIDStanza }}setuid {{ .UserName }}{{ end }}
respawn
respawn limit 10 5
umask 022
console none
pre-start script
test -x {{ .Path }} || { stop; exit 0; }
end script
# Start
script
{{ if .LogOutput }}
stdout_log="{{ .LogDirectory }}/{{ .Name }}.out"
stderr_log="{{ .LogDirectory }}/{{ .Name }}.err"
{{ end }}
if [ -f "/etc/sysconfig/{{ .Name }}" ]; then
set -a
source /etc/sysconfig/{{ .Name }}
set +a
fi
exec {{ if and .UserName (not .HasSetUIDStanza) }}sudo -E -u {{ .UserName }} {{ end }}{{ .Path }}{{ range .Arguments }} {{ . | cmd }}{{ end }}{{ if .LogOutput }} >> $stdout_log 2>> $stderr_log{{ end }}
end script