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,43 @@
load(
"@io_bazel_rules_go//go:def.bzl",
"go_library",
"go_binary",
)
go_library(
name = "go_default_library",
srcs = ["main.go"],
data = ["identify-game-service.toml"],
importpath = "go-common/app/service/main/identify-game/cmd",
tags = ["automanaged"],
visibility = ["//visibility:private"],
deps = [
"//app/service/main/identify-game/conf:go_default_library",
"//app/service/main/identify-game/rpc/server:go_default_library",
"//app/service/main/identify-game/server/grpc:go_default_library",
"//app/service/main/identify-game/server/http:go_default_library",
"//app/service/main/identify-game/service:go_default_library",
"//library/log:go_default_library",
"//library/net/trace:go_default_library",
],
)
go_binary(
name = "cmd",
embed = [":go_default_library"],
visibility = ["//visibility:public"],
)
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,63 @@
# This is a TOML document. Boom.
[bm]
addr = "0.0.0.0:7391"
timeout = "1s"
[rpcServer]
proto = "tcp"
addr = "0.0.0.0:7399"
timeout = "30s"
[passport]
[passport.host]
auth = "http://passport.bilibili.co"
[HTTPClient]
key = "7d9f6f6fe2a898e8"
secret = "4de2ccdbd9db69be0c2c6437bfe6eb69"
dial = "50ms"
timeout = "200ms"
keepAlive = "60s"
[HTTPClient.breaker]
window ="1s"
sleep ="10ms"
bucket = 10
ratio = 0.5
request = 100
[memcache]
name = "identify-game-service"
proto = "tcp"
addr = "172.18.33.61:11235"
idle = 5
active = 10
dialTimeout = "1s"
readTimeout = "1s"
writeTimeout = "1s"
idleTimeout = "10s"
expire = "10h"
[dispatcher]
name = "origin"
[dispatcher.oauth]
"origin" = "http://passport.bilibili.com/api/oauth"
"t1" = "http://api.bilibili.com/x/passport-game/oauth"
"t2" = "http://t2-api.bilibili.com/x/passport-game/oauth"
[dispatcher.renewToken]
"origin" = "http://passport.bilibili.com/api/login/renewToken"
"t1" = "http://api.bilibili.com/x/passport-game/renewtoken"
"t2" = "http://t2-api.bilibili.com/x/passport-game/renewtoken"
[[dispatcher.regionInfos]]
region = "市北"
tokenSuffix = ""
[[dispatcher.regionInfos]]
region = "腾讯云1"
tokenSuffix = "t1"
[[dispatcher.regionInfos]]
region = "腾讯云2"
tokenSuffix = "t2"

View File

@@ -0,0 +1,58 @@
package main
import (
"context"
"flag"
"go-common/app/service/main/identify-game/server/grpc"
"os"
"os/signal"
"syscall"
"time"
"go-common/app/service/main/identify-game/conf"
rpc "go-common/app/service/main/identify-game/rpc/server"
"go-common/app/service/main/identify-game/server/http"
"go-common/app/service/main/identify-game/service"
"go-common/library/log"
"go-common/library/net/trace"
)
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)
rpcSvr := rpc.New(conf.Conf, svr)
http.Init(conf.Conf, svr)
// init warden server
ws := grpc.New(conf.Conf.WardenServer, svr)
// signal handler
log.Info("identify-game-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-game-service get a signal %s", s.String())
switch s {
case syscall.SIGQUIT, syscall.SIGTERM, syscall.SIGINT:
rpcSvr.Close()
time.Sleep(time.Second * 2)
svr.Close()
ws.Shutdown(context.Background())
log.Info("identify-game-service exit")
return
case syscall.SIGHUP:
default:
return
}
}
}