зеркало из https://github.com/mozilla/mig.git
[minor] use osext module to find agent executable path
This commit is contained in:
Родитель
2bf8db4f52
Коммит
c0cfcf8ccb
1
Makefile
1
Makefile
|
@ -68,6 +68,7 @@ go_get_deps:
|
|||
$(GOGETTER) github.com/VividCortex/godaemon
|
||||
$(GOGETTER) github.com/gorilla/mux
|
||||
$(GOGETTER) github.com/jvehent/cljs
|
||||
$(GOGETTER) bitbucket.org/kardianos/osext
|
||||
|
||||
install: gpgme mig-agent mig-scheduler
|
||||
$(INSTALL) -D -m 0755 $(BINDIR)/mig-agent $(DESTDIR)$(PREFIX)/sbin/mig-agent
|
||||
|
|
|
@ -36,6 +36,7 @@ the terms of any one of the MPL, the GPL or the LGPL.
|
|||
package main
|
||||
|
||||
import (
|
||||
"bitbucket.org/kardianos/osext"
|
||||
"crypto/rand"
|
||||
"crypto/tls"
|
||||
"crypto/x509"
|
||||
|
@ -95,18 +96,10 @@ func Init(foreground bool) (ctx Context, err error) {
|
|||
ctx.Channels.Log <- mig.Log{Desc: "leaving initAgent()"}.Debug()
|
||||
}()
|
||||
|
||||
// find out current working dir and build the bin path
|
||||
// it's important to do that before we daemonize, other the cwd will be /
|
||||
cdir := ""
|
||||
char := fmt.Sprintf("%c", os.Args[0][0])
|
||||
if char == "." {
|
||||
// command start with a dot, prepend the current dir
|
||||
cdir, err = os.Getwd()
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
ctx.Agent.BinPath, err = osext.Executable()
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
ctx.Agent.BinPath = cdir + "/" + os.Args[0]
|
||||
|
||||
// daemonize, and force logging to stdout
|
||||
if !foreground && LOGGINGCONF.Mode != "stdout" {
|
||||
|
|
Загрузка…
Ссылка в новой задаче