Create & Init Project...

This commit is contained in:
2019-04-22 18:49:16 +08:00
commit fc4fa37393
25440 changed files with 4054998 additions and 0 deletions

View File

@@ -0,0 +1,42 @@
package(default_visibility = ["//visibility:public"])
load(
"@io_bazel_rules_go//go:def.bzl",
"go_binary",
"go_library",
)
go_binary(
name = "cmd",
embed = [":go_default_library"],
tags = ["automanaged"],
)
go_library(
name = "go_default_library",
srcs = ["main.go"],
data = ["easyns-agent-example.toml"],
importpath = "go-common/app/service/main/bns/cmd",
tags = ["automanaged"],
visibility = ["//visibility:public"],
deps = [
"//app/service/main/bns/agent:go_default_library",
"//app/service/main/bns/agent/backend/discovery:go_default_library",
"//app/service/main/bns/conf:go_default_library",
"//library/log:go_default_library",
],
)
filegroup(
name = "package-srcs",
srcs = glob(["**"]),
tags = ["automanaged"],
visibility = ["//visibility:private"],
)
filegroup(
name = "all-srcs",
srcs = [":package-srcs"],
tags = ["automanaged"],
visibility = ["//visibility:public"],
)

View File

@@ -0,0 +1,30 @@
version = "0.1"
debug = false
[protocol]
version = "1"
[log]
stdout = true
[backend]
backend = "discovery"
[backend.config]
url = "http://api.bilibili.co"
appKey = "0c4b8fe3ff35a4b6"
secret = "b370880d1aca7d3a289b9b9a7f4d6812"
[dns]
addr = "127.0.0.1"
port = 15353
[dns.config]
ttl = "30s"
allowStale = true
udpAnswerLimit = 3
maxStale = "87600s"
recursorTimeout = "2s"
domain = "bili."
recursors = ["10.23.194.202"]
[http]
addr = "127.0.0.1"
port = 15380

View File

@@ -0,0 +1,60 @@
package main
import (
"flag"
"fmt"
"os"
"os/signal"
"syscall"
"go-common/app/service/main/bns/agent"
"go-common/app/service/main/bns/conf"
"go-common/library/log"
_ "go-common/app/service/main/bns/agent/backend/discovery"
)
var confPath string
func init() {
flag.StringVar(&confPath, "conf", "", "default config path")
}
func main() {
if !flag.Parsed() {
flag.Parse()
}
cfg, err := conf.LoadConfig(confPath)
if err != nil {
panic(fmt.Sprintf("loadconfig from: %s error: %s", confPath, err))
}
log.Init(cfg.Log)
defer log.Close()
ag, err := agent.New(cfg)
if err != nil {
panic(err)
}
if err := ag.Start(); err != nil {
panic(err)
}
log.Info("bns start ...")
ch := make(chan os.Signal, 1)
signal.Notify(ch, syscall.SIGHUP, syscall.SIGQUIT, syscall.SIGTERM, syscall.SIGINT)
for s := range ch {
log.Info("bns get a signal %s", s.String())
switch s {
case syscall.SIGQUIT, syscall.SIGTERM, syscall.SIGINT:
log.Info("bns exit ...")
return
case syscall.SIGHUP:
log.Warn("reload is not support yet!")
default:
os.Exit(1)
}
}
}