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,44 @@
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 = ["identify-service-test.toml"],
importpath = "go-common/app/service/main/identify/cmd",
tags = ["automanaged"],
visibility = ["//visibility:public"],
deps = [
"//app/service/main/identify/conf:go_default_library",
"//app/service/main/identify/server/grpc:go_default_library",
"//app/service/main/identify/server/http:go_default_library",
"//app/service/main/identify/service:go_default_library",
"//library/log:go_default_library",
"//library/net/trace: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,83 @@
# This is a TOML document. Boom.
[Identify]
authHost = "http://passport.bilibili.co"
# sync whith userlog databus
LoginLogConsumerSize = 10
IntranetCIDR = ["172.16.0.0/12", "10.0.0.0/8", "192.168.0.0/16"]
[rpcServer2]
[[rpcServer2.servers]]
proto = "tcp"
addr = "0.0.0.0:7379"
weight = 10
[rpcServer2.zookeeper]
root = "/microservice/identify-service/"
addrs = ["172.18.33.172:2181"]
timeout = "1s"
[bm]
addr = "0.0.0.0:7371"
timeout = "1s"
[HTTPClient]
dial = "50ms"
timeout = "200ms"
keepAlive = "60s"
key = "f265dcfa28272742"
secret = "437facc22dc8698b5544669bcc12348d"
[HTTPClient.breaker]
window ="1s"
sleep ="10ms"
bucket = 10
ratio = 0.5
request = 100
[Memcache]
name = "identify-service"
proto = "tcp"
addr = "172.18.33.61:11234"
idle = 1000
active = 1000
dialTimeout = "10s"
readTimeout = "10s"
writeTimeout = "10s"
idleTimeout = "30s"
settingExpire = "720h"
reportExpire = "720h"
[wardenServer]
addr = "0.0.0.0:6077"
timeout = "1s"
[liveZK]
addrs = ["172.16.33.249:2189"]
timeout = "1s"
[databus.userLog]
key = "2511663d546f1413"
secret = "cde3b480836cc76df3d635470f991caa"
group = "LogUserAction-MainSearch-P"
topic = "LogUserAction-T"
action = "pub"
buffer = 10240
name = "log-user-action/log-sub"
proto = "tcp"
addr = "172.18.33.50:6205"
idle = 10
active = 10
dialTimeout = "1s"
readTimeout = "60s"
writeTimeout = "1s"
idleTimeout = "10s"
[MemcacheLoginLog]
name = "identify-service"
proto = "tcp"
addr = "172.18.33.61:11234"
idle = 1000
active = 1000
dialTimeout = "10s"
readTimeout = "10s"
writeTimeout = "10s"
idleTimeout = "30s"
settingExpire = "720h"
reportExpire = "720h"

View File

@@ -0,0 +1,67 @@
package main
import (
"context"
"flag"
"os"
"os/signal"
"syscall"
"time"
"go-common/app/service/main/identify/conf"
"go-common/app/service/main/identify/server/grpc"
"go-common/app/service/main/identify/server/http"
"go-common/app/service/main/identify/service"
"go-common/library/log"
// "go-common/library/net/rpc/warden/resolver/livezk"
"go-common/library/net/trace"
)
const (
// discoveryID = "passport.service.identify"
)
func main() {
flag.Parse()
// init conf,log,trace,stat,perf.
if err := conf.Init(); err != nil {
panic(err)
}
log.Init(conf.Conf.Xlog)
defer log.Close()
trace.Init(conf.Conf.Tracer)
defer trace.Close()
// service init
svr := service.New(conf.Conf)
http.Init(conf.Conf, svr)
// init warden server
ws := grpc.New(conf.Conf.WardenServer, svr)
// 先主站内部和chenzhihui测试可用再对外提供
// cancel, err := livezk.Register(conf.Conf.LiveZK, conf.Conf.WardenServer.Addr, discoveryID)
// if err != nil {
// panic(err)
// }
// signal handler
log.Info("identify-service start")
c := make(chan os.Signal, 1)
signal.Notify(c, syscall.SIGHUP, syscall.SIGQUIT, syscall.SIGTERM, syscall.SIGINT)
for {
s := <-c
log.Info("identify-service get a signal %s", s.String())
switch s {
case syscall.SIGQUIT, syscall.SIGTERM, syscall.SIGSTOP, syscall.SIGINT:
// cancel()
ws.Shutdown(context.Background())
time.Sleep(time.Second * 2)
svr.Close()
log.Info("identify-service exit")
return
case syscall.SIGHUP:
// TODO reload
default:
return
}
}
}