From 994866c14a5d76144f8149787ee5107661c47de2 Mon Sep 17 00:00:00 2001 From: SteelPhase Date: Mon, 20 Aug 2018 23:18:32 -0400 Subject: [PATCH] add file logging support to systemd --- service_systemd_linux.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/service_systemd_linux.go b/service_systemd_linux.go index 26c0eda..b7d63bc 100644 --- a/service_systemd_linux.go +++ b/service_systemd_linux.go @@ -82,11 +82,13 @@ func (s *systemd) Install() error { Path string ReloadSignal string PIDFile string + LogOutput bool }{ s.Config, path, s.Option.string(optionReloadSignal, ""), s.Option.string(optionPIDFile, ""), + s.Option.bool(optionLogOutput, optionLogOutputDefault), } err = s.template().Execute(f, to) @@ -166,6 +168,8 @@ ExecStart={{.Path|cmdEscape}}{{range .Arguments}} {{.|cmd}}{{end}} {{if .UserName}}User={{.UserName}}{{end}} {{if .ReloadSignal}}ExecReload=/bin/kill -{{.ReloadSignal}} "$MAINPID"{{end}} {{if .PIDFile}}PIDFile={{.PIDFile|cmd}}{{end}} +{{if .LogOutput}}StandardOutput=file:/var/log/{{.Name}}.out" +StandardError=file:/var/log/{{.Name}}.err{{end}} Restart=always RestartSec=120 EnvironmentFile=-/etc/sysconfig/{{.Name}}