mirror of
https://github.com/Control-D-Inc/ctrld.git
synced 2026-02-03 22:18:39 +00:00
cmd/ctrld: restoring DNS on darwin before stop
Otherwise, we experiment with ctrld slow start after rebooting, because the network check continuously report failed status even the network state is up. Restoring the DNS before stopping, we leave the network state as default, as long as ctrld starts, the DNS is configured again.
This commit is contained in:
committed by
Cuong Manh Le
parent
21c8b9f8e7
commit
d3d08022cc
@@ -138,6 +138,7 @@ func (p *prog) Stop(s service.Service) error {
|
||||
mainLog.Error().Err(err).Msg("de-allocate ip failed")
|
||||
return err
|
||||
}
|
||||
p.preStop()
|
||||
mainLog.Info().Msg("Service stopped")
|
||||
close(p.stopCh)
|
||||
return nil
|
||||
|
||||
23
cmd/ctrld/prog_darwin.go
Normal file
23
cmd/ctrld/prog_darwin.go
Normal file
@@ -0,0 +1,23 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"github.com/kardianos/service"
|
||||
)
|
||||
|
||||
func (p *prog) preRun() {
|
||||
if !service.Interactive() {
|
||||
p.setDNS()
|
||||
}
|
||||
}
|
||||
|
||||
func setDependencies(svc *service.Config) {}
|
||||
|
||||
func setWorkingDirectory(svc *service.Config, dir string) {
|
||||
svc.WorkingDirectory = dir
|
||||
}
|
||||
|
||||
func (p *prog) preStop() {
|
||||
if !service.Interactive() {
|
||||
p.resetDNS()
|
||||
}
|
||||
}
|
||||
@@ -18,3 +18,5 @@ func setDependencies(svc *service.Config) {
|
||||
}
|
||||
|
||||
func setWorkingDirectory(svc *service.Config, dir string) {}
|
||||
|
||||
func (p *prog) preStop() {}
|
||||
|
||||
@@ -22,3 +22,5 @@ func setDependencies(svc *service.Config) {
|
||||
func setWorkingDirectory(svc *service.Config, dir string) {
|
||||
svc.WorkingDirectory = dir
|
||||
}
|
||||
|
||||
func (p *prog) preStop() {}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
//go:build !linux && !freebsd
|
||||
//go:build !linux && !freebsd && !darwin
|
||||
|
||||
package main
|
||||
|
||||
@@ -12,3 +12,5 @@ func setWorkingDirectory(svc *service.Config, dir string) {
|
||||
// WorkingDirectory is not supported on Windows.
|
||||
svc.WorkingDirectory = dir
|
||||
}
|
||||
|
||||
func (p *prog) preStop() {}
|
||||
|
||||
Reference in New Issue
Block a user