Making '-service' flags work from a non-interactive session, i.e. Ansible, related to #1760
This commit is contained in:
parent
32268fb25b
commit
e477620dc5
|
@ -182,15 +182,6 @@ func reloadLoop(stop chan struct{}, s service.Service) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
case *fService != "" && runtime.GOOS == "windows":
|
|
||||||
if *fConfig != "" {
|
|
||||||
(*svcConfig).Arguments = []string{"-config", *fConfig}
|
|
||||||
}
|
|
||||||
err := service.Control(s, *fService)
|
|
||||||
if err != nil {
|
|
||||||
log.Fatal(err)
|
|
||||||
}
|
|
||||||
return
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// If no other options are specified, load the config file and run.
|
// If no other options are specified, load the config file and run.
|
||||||
|
@ -320,10 +311,23 @@ func main() {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
}
|
}
|
||||||
|
// Handle the -service flag here to prevent any issues with tooling that may not have an interactive
|
||||||
|
// session, e.g. installing from Ansible
|
||||||
|
flag.Parse()
|
||||||
|
if *fService != "" {
|
||||||
|
if *fConfig != "" {
|
||||||
|
(*svcConfig).Arguments = []string{"-config", *fConfig}
|
||||||
|
}
|
||||||
|
err := service.Control(s, *fService)
|
||||||
|
if err != nil {
|
||||||
|
log.Fatal(err)
|
||||||
|
}
|
||||||
|
} else {
|
||||||
err = s.Run()
|
err = s.Run()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logger.Error(err)
|
logger.Error(err)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
stop = make(chan struct{})
|
stop = make(chan struct{})
|
||||||
reloadLoop(stop, nil)
|
reloadLoop(stop, nil)
|
||||||
|
|
Loading…
Reference in New Issue