From 9bdb7cc62156f2a43141942fb471b447960d765d Mon Sep 17 00:00:00 2001 From: Kim min cheol Date: Mon, 3 Dec 2018 13:28:25 +0900 Subject: [PATCH] add EnvironmentFile option enable --- daemon_linux_systemd.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/daemon_linux_systemd.go b/daemon_linux_systemd.go index bfd928b..79a8f10 100644 --- a/daemon_linux_systemd.go +++ b/daemon_linux_systemd.go @@ -75,6 +75,8 @@ func (linux *systemDRecord) Install(args ...string) (string, error) { if err != nil { return installAction + failed, err } + + execDir := path.Dir(execPatch) templ, err := template.New("systemDConfig").Parse(systemDConfig) if err != nil { @@ -84,12 +86,13 @@ func (linux *systemDRecord) Install(args ...string) (string, error) { if err := templ.Execute( file, &struct { - Name, Description, Dependencies, Path, Args string + Name, Description, Dependencies, Path, Dir, Args string }{ linux.name, linux.description, strings.Join(linux.dependencies, " "), execPatch, + execDir, strings.Join(args, " "), }, ); err != nil { @@ -205,6 +208,7 @@ Requires={{.Dependencies}} After={{.Dependencies}} [Service] +EnvironmentFile={{.Dir}}/.env PIDFile=/var/run/{{.Name}}.pid ExecStartPre=/bin/rm -f /var/run/{{.Name}}.pid ExecStart={{.Path}} {{.Args}}