Provide custom log directory for posix (#311)

When running a service with posix, provide a custom path to the
service output
This commit is contained in:
tomfeigin
2022-04-28 15:56:17 +03:00
committed by GitHub
parent bc65850ac5
commit abe98a9274
7 changed files with 52 additions and 30 deletions
+5 -4
View File
@@ -60,9 +60,8 @@ func (s *openrc) template() *template.Template {
if customScript != "" {
return template.Must(template.New("").Funcs(tf).Parse(customScript))
} else {
return template.Must(template.New("").Funcs(tf).Parse(openRCScript))
}
return template.Must(template.New("").Funcs(tf).Parse(openRCScript))
}
func newOpenRCService(i Interface, platform string, c *Config) (Service, error) {
@@ -113,10 +112,12 @@ func (s *openrc) Install() error {
var to = &struct {
*Config
Path string
Path string
LogDirectory string
}{
s.Config,
path,
s.Option.string(optionLogDirectory, defaultLogDirectory),
}
err = s.template().Execute(f, to)
@@ -227,7 +228,7 @@ command={{.Path|cmdEscape}}
command_args="{{range .Arguments}}{{.}} {{end}}"
{{- end }}
name=$(basename $(readlink -f $command))
supervise_daemon_args="--stdout /var/log/${name}.log --stderr /var/log/${name}.err"
supervise_daemon_args="--stdout {{.LogDirectory}}/${name}.log --stderr {{.LogDirectory}}/${name}.err"
{{- if .Dependencies }}
depend() {