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:
parent
3a6a8010b9
commit
4fc2c57fff
15
.gitlab-ci.yml
Normal file
15
.gitlab-ci.yml
Normal 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
13
dns_handler_test.go
Normal 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...")
|
||||||
|
}
|
||||||
|
}
|
31
godns.go
31
godns.go
@ -5,10 +5,7 @@ import (
|
|||||||
"log"
|
"log"
|
||||||
"runtime/debug"
|
"runtime/debug"
|
||||||
"strings"
|
"strings"
|
||||||
"syscall"
|
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"bitbucket.org/abotoo/gonohup"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
@ -37,35 +34,7 @@ func main() {
|
|||||||
|
|
||||||
Configuration = LoadSettings(*optConf)
|
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()
|
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() {
|
func dns_loop() {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user