Hotfix for OpenBSD and other OS whose init system is not supported yet
This commit is contained in:
parent
857dc9e2cd
commit
0e03f684b2
|
@ -33,7 +33,7 @@ script:
|
|||
- zip -9 -r dnscrypt-proxy-win64-${TRAVIS_TAG:-dev}.zip win64
|
||||
|
||||
- go clean
|
||||
- env GOOS=openbsd GOARCH=386 go build -ldflags="-s -w"
|
||||
- env GO386=387 GOOS=openbsd GOARCH=386 go build -ldflags="-s -w"
|
||||
- mkdir openbsd-i386
|
||||
- ln dnscrypt-proxy openbsd-i386/
|
||||
- ln ../LICENSE dnscrypt-proxy.toml forwarding-rules.txt blacklist.txt openbsd-i386/
|
||||
|
|
|
@ -61,7 +61,8 @@ func main() {
|
|||
app := &App{}
|
||||
svc, err := service.New(app, svcConfig)
|
||||
if err != nil {
|
||||
dlog.Fatal(err)
|
||||
svc = nil
|
||||
dlog.Debug(err)
|
||||
}
|
||||
app.proxy = Proxy{}
|
||||
if err := ConfigLoad(&app.proxy, svcFlag, "dnscrypt-proxy.toml"); err != nil {
|
||||
|
@ -84,8 +85,12 @@ func main() {
|
|||
}
|
||||
return
|
||||
}
|
||||
if err = svc.Run(); err != nil {
|
||||
dlog.Fatal(err)
|
||||
if svc != nil {
|
||||
if err = svc.Run(); err != nil {
|
||||
dlog.Fatal(err)
|
||||
}
|
||||
} else {
|
||||
app.Start(nil)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -99,15 +104,23 @@ func (app *App) Start(service service.Service) error {
|
|||
}
|
||||
app.quit = make(chan struct{})
|
||||
app.wg.Add(1)
|
||||
go func() {
|
||||
proxy.StartProxy()
|
||||
<-app.quit
|
||||
dlog.Notice("Quit signal received...")
|
||||
app.wg.Done()
|
||||
}()
|
||||
if service != nil {
|
||||
go func() {
|
||||
app.AppMain(&proxy)
|
||||
}()
|
||||
} else {
|
||||
app.AppMain(&proxy)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (app *App) AppMain(proxy *Proxy) {
|
||||
proxy.StartProxy()
|
||||
<-app.quit
|
||||
dlog.Notice("Quit signal received...")
|
||||
app.wg.Done()
|
||||
}
|
||||
|
||||
func (app *App) Stop(service service.Service) error {
|
||||
dlog.Notice("Stopped.")
|
||||
return nil
|
||||
|
|
Loading…
Reference in New Issue