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
+6 -5
View File
@@ -58,9 +58,8 @@ func (s *sysv) template() *template.Template {
if customScript != "" {
return template.Must(template.New("").Funcs(tf).Parse(customScript))
} else {
return template.Must(template.New("").Funcs(tf).Parse(sysvScript))
}
return template.Must(template.New("").Funcs(tf).Parse(sysvScript))
}
func (s *sysv) Install() error {
@@ -86,10 +85,12 @@ func (s *sysv) 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)
@@ -203,8 +204,8 @@ cmd="{{.Path}}{{range .Arguments}} {{.|cmd}}{{end}}"
name=$(basename $(readlink -f $0))
pid_file="/var/run/$name.pid"
stdout_log="/var/log/$name.log"
stderr_log="/var/log/$name.err"
stdout_log="{{.LogDirectory}}/$name.log"
stderr_log="{{.LogDirectory}}/$name.err"
[ -e /etc/sysconfig/$name ] && . /etc/sysconfig/$name