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,9 +311,22 @@ func main() {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
}
|
}
|
||||||
err = s.Run()
|
// Handle the -service flag here to prevent any issues with tooling that may not have an interactive
|
||||||
if err != nil {
|
// session, e.g. installing from Ansible
|
||||||
logger.Error(err)
|
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()
|
||||||
|
if err != nil {
|
||||||
|
logger.Error(err)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
stop = make(chan struct{})
|
stop = make(chan struct{})
|
||||||
|
|
Loading…
Reference in New Issue