Use osext package for getting the executable name.

This commit is contained in:
Daniel Theophanes
2013-01-11 16:54:30 -08:00
parent a3c4739864
commit da2c993cb8
4 changed files with 13 additions and 71 deletions
+2 -8
View File
@@ -1,13 +1,13 @@
package service
import (
"bitbucket.org/kardianos/osext"
"fmt"
"log/syslog"
"os"
"os/exec"
"os/signal"
"text/template"
"path/filepath"
)
func newService(name, displayName, description string) (s *linuxUpstartService, err error) {
@@ -43,7 +43,7 @@ func (s *linuxUpstartService) Install() error {
}
defer f.Close()
path, err := getExePath()
path, err := osext.Executable()
if err != nil {
return err
}
@@ -109,12 +109,6 @@ func (s *linuxUpstartService) LogInfo(format string, a ...interface{}) error {
return s.logger.Info(fmt.Sprintf(format, a...))
}
func getExePath() (exePath string, err error) {
exePath, err = os.Readlink(`/proc/self/exe`)
exePath = filepath.Clean(exePath)
return
}
var upstartScript = `# {{.Description}}
description "{{.Display}}"