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,41 @@
load(
"@io_bazel_rules_go//go:def.bzl",
"go_library",
"go_binary",
)
go_library(
name = "go_default_library",
srcs = ["main.go"],
data = ["passport-game-service.toml"],
importpath = "go-common/app/service/main/passport-game/cmd",
tags = ["automanaged"],
visibility = ["//visibility:private"],
deps = [
"//app/service/main/passport-game/conf:go_default_library",
"//app/service/main/passport-game/http:go_default_library",
"//app/service/main/passport-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,48 @@
package main
import (
"flag"
"os"
"os/signal"
"syscall"
"time"
"go-common/app/service/main/passport-game/conf"
"go-common/app/service/main/passport-game/http"
"go-common/app/service/main/passport-game/service"
"go-common/library/log"
"go-common/library/net/trace"
)
func main() {
flag.Parse()
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
srv := service.New(conf.Conf)
http.Init(conf.Conf, srv)
// signal handler
log.Info("passport-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("passport-game-service get a signal %s", s.String())
switch s {
case syscall.SIGQUIT, syscall.SIGTERM, syscall.SIGINT:
srv.Close()
time.Sleep(time.Second * 2)
log.Info("passport-game-service exit")
return
case syscall.SIGHUP:
// TODO reload
default:
return
}
}
}

View File

@@ -0,0 +1,87 @@
# This is a TOML document. Boom.
# 这个项目比较特殊,部署在云上的,需要保留一下配置
proxy = false
accountURI = "http://account.bilibili.co"
passportURI = "http://passport.bilibili.com"
family = "passport-game-service"
env = "qa"
[db.cloud]
addr = "172.16.33.205:3306"
dsn = "account:wx2U1MwXRyWEuURw@tcp(172.16.33.205:3306)/member_app1?timeout=5s&readTimeout=5s&writeTimeout=5s&parseTime=true&loc=Local&charset=utf8,utf8mb4"
active = 5
idle = 2
queryTimeout = "1s"
execTimeout = "2s"
tranTimeout = "2s"
[db.cloud.breaker]
window = "3s"
sleep = "100ms"
bucket = 10
ratio = 0.5
request = 100
[db.otherRegion]
addr = "172.16.33.205:3306"
dsn = "account:wx2U1MwXRyWEuURw@tcp(172.16.33.205:3306)/member_app2?timeout=5s&readTimeout=5s&writeTimeout=5s&parseTime=true&loc=Local&charset=utf8,utf8mb4"
active = 5
idle = 2
queryTimeout = "1s"
execTimeout = "2s"
tranTimeout = "2s"
[db.otherRegion.breaker]
window = "3s"
sleep = "100ms"
bucket = 10
ratio = 0.5
request = 100
[memcache]
name = "passport-game-service"
proto = "tcp"
addr = "172.16.33.54:21211"
idle = 5
active = 10
dialTimeout = "1s"
readTimeout = "1s"
writeTimeout = "1s"
idleTimeout = "10s"
expire = "10h"
[httpClient]
key = "868fb9ea57619022"
secret = "test"
dial = "5s"
timeout = "10s"
keepAlive = "6s"
timer = 10
[httpClient.breaker]
window = "3s"
sleep = "100ms"
bucket = 10
ratio = 0.5
request = 100
[dispatcher]
name = "t1"
[dispatcher.oauth]
"origin"="http://api.bilibili.co/x/internal/identify-game/oauth"
"t1" = "http://api.bilibili.com/x/passport-game/oauth"
"t2" = "http://t2-api.bilibili.com/x/passport-game/oauth"
[dispatcher.renewToken]
"origin"="http://api.bilibili.co/x/internal/identify-game/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"