1
0
mirror of https://github.com/taigrr/godns synced 2025-01-18 04:03:25 -08:00

Remove gonohup to support windows

This commit is contained in:
Timothy 2016-05-11 14:43:17 +08:00
parent 3a6a8010b9
commit 4fc2c57fff
3 changed files with 28 additions and 31 deletions

15
.gitlab-ci.yml Normal file
View File

@ -0,0 +1,15 @@
stages:
- build
- test
build-my-project:
stage: build
script:
- cd $CURRENT_BUILD_PATH
- go build
test-my-project:
stage: test
script:
- cd $CURRENT_BUILD_PATH
- go test

13
dns_handler_test.go Normal file
View File

@ -0,0 +1,13 @@
package main
import (
"testing"
)
func Test_get_current_IP(t *testing.T) {
ip, _ := get_currentIP("http://members.3322.org/dyndns/getip")
if ip == "" {
t.Error("Cannot get IP...")
}
}

View File

@ -5,10 +5,7 @@ import (
"log"
"runtime/debug"
"strings"
"syscall"
"time"
"bitbucket.org/abotoo/gonohup"
)
const (
@ -37,35 +34,7 @@ func main() {
Configuration = LoadSettings(*optConf)
ctx := gonohup.Context{
Hash: "godns",
User: Configuration.User,
Group: Configuration.Group,
Command: *optCommand,
}
sig, err := gonohup.Daemonize(ctx)
if err != nil {
log.Println("Daemonize:", err)
return
}
err = gonohup.InitLogger(Configuration.Log_Path, Configuration.Log_Size, Configuration.Log_Num)
if err != nil {
log.Println("InitLogger error:", err)
return
}
go dns_loop()
for s := range sig {
switch s {
case syscall.SIGHUP, syscall.SIGUSR2:
// do some custom jobs while reload/hotupdate
case syscall.SIGTERM:
// do some clean up and exit
return
}
}
}
func dns_loop() {