Hotfix for OpenBSD and other OS whose init system is not supported yet

This commit is contained in:
Frank Denis 2018-01-18 02:07:31 +01:00
parent 857dc9e2cd
commit 0e03f684b2
2 changed files with 23 additions and 10 deletions

View File

@ -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/

View File

@ -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,9 +85,13 @@ func main() {
}
return
}
if svc != nil {
if err = svc.Run(); err != nil {
dlog.Fatal(err)
}
} else {
app.Start(nil)
}
}
func (app *App) Start(service service.Service) error {
@ -99,13 +104,21 @@ func (app *App) Start(service service.Service) error {
}
app.quit = make(chan struct{})
app.wg.Add(1)
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()
}()
return nil
}
func (app *App) Stop(service service.Service) error {