mirror of
https://github.com/Control-D-Inc/ctrld.git
synced 2026-08-10 13:20:33 +02:00
cmd/ctrld: start service before restart on Windows
On Windows, calling s.Restart will fail if service is not running, ensure ctrld is started before calling restart.
This commit is contained in:
+14
-3
@@ -453,7 +453,7 @@ func initCLI() {
|
|||||||
}
|
}
|
||||||
// On Linux, Darwin, Freebsd, ctrld set DNS on startup, because the DNS setting could be
|
// On Linux, Darwin, Freebsd, ctrld set DNS on startup, because the DNS setting could be
|
||||||
// reset after rebooting. On windows, we only need to set once here. See prog.preRun in
|
// reset after rebooting. On windows, we only need to set once here. See prog.preRun in
|
||||||
// prog_*.go file for dedicated code on each platform.
|
// prog_*.go file for dedicated code on each platform. (1)
|
||||||
if runtime.GOOS == "windows" {
|
if runtime.GOOS == "windows" {
|
||||||
p.setDNS()
|
p.setDNS()
|
||||||
}
|
}
|
||||||
@@ -525,7 +525,10 @@ func initCLI() {
|
|||||||
initLogging()
|
initLogging()
|
||||||
if doTasks([]task{{s.Stop, true}}) {
|
if doTasks([]task{{s.Stop, true}}) {
|
||||||
p.router.Cleanup()
|
p.router.Cleanup()
|
||||||
p.resetDNS()
|
// See comment (1) in startCmd.
|
||||||
|
if runtime.GOOS != "windows" {
|
||||||
|
p.resetDNS()
|
||||||
|
}
|
||||||
mainLog.Load().Notice().Msg("Service stopped")
|
mainLog.Load().Notice().Msg("Service stopped")
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@@ -547,7 +550,15 @@ func initCLI() {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
initLogging()
|
initLogging()
|
||||||
if doTasks([]task{{s.Restart, true}}) {
|
tasks := []task{{s.Restart, true}}
|
||||||
|
// On Windows, s.Restart will return error unless service is running.
|
||||||
|
if runtime.GOOS == "windows" {
|
||||||
|
tasks = []task{
|
||||||
|
{s.Start, false},
|
||||||
|
{s.Restart, true},
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if doTasks(tasks) {
|
||||||
mainLog.Load().Notice().Msg("Service restarted")
|
mainLog.Load().Notice().Msg("Service restarted")
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user