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,48 @@
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 = [
"passport-auth-service.toml",
"passport-auth-service-uat.toml",
],
importpath = "go-common/app/service/main/passport-auth/cmd",
tags = ["automanaged"],
visibility = ["//visibility:public"],
deps = [
"//app/service/main/passport-auth/conf:go_default_library",
"//app/service/main/passport-auth/http:go_default_library",
"//app/service/main/passport-auth/rpc/grpc:go_default_library",
"//app/service/main/passport-auth/rpc/server:go_default_library",
"//app/service/main/passport-auth/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,53 @@
package main
import (
"context"
"flag"
"os"
"os/signal"
"syscall"
"time"
"go-common/app/service/main/passport-auth/conf"
"go-common/app/service/main/passport-auth/http"
"go-common/app/service/main/passport-auth/rpc/grpc"
rpc "go-common/app/service/main/passport-auth/rpc/server"
"go-common/app/service/main/passport-auth/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()
svr := service.New(conf.Conf)
// rpc server init
rpcSvr := rpc.New(conf.Conf, svr)
ws := grpc.New(conf.Conf.WardenServer, svr)
http.Init(conf.Conf, svr)
// signal handler
log.Info("passport-auth-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-auth-service get a signal %s", s.String())
switch s {
case syscall.SIGQUIT, syscall.SIGTERM, syscall.SIGINT:
ws.Shutdown(context.Background())
rpcSvr.Close()
time.Sleep(time.Second * 2)
log.Info("passport-auth-service exit")
return
case syscall.SIGHUP:
default:
return
}
}
}

View File

@@ -0,0 +1,45 @@
[rpcServer2]
[[rpcServer2.servers]]
proto = "tcp"
addr = "0.0.0.0:9009"
weight = 10
[rpcServer2.zookeeper]
root = "/microservice/passport-auth-service/"
addrs = ["172.18.33.50:2199","172.18.33.51:2199","172.18.33.52:2199"]
timeout = "1s"
[mysql]
addr = "172.22.34.101:3308"
dsn = "auth:ABQ3ewVrxyZsLpWb0EkJuCvN9M8aidf7@tcp(172.22.34.101:3308)/passport_auth?timeout=200ms&readTimeout=200ms&writeTimeout=200ms&parseTime=true&loc=Local&charset=utf8,utf8mb4"
readDSN = ["auth_reader:3odEZJ7YlOLpNzt4XVDxHTw9bi08C1M2@tcp(172.22.34.101:3308)/passport_auth?timeout=200ms&readTimeout=200ms&writeTimeout=200ms&parseTime=true&loc=Local&charset=utf8,utf8mb4"]
active = 10
idle = 10
idleTimeout ="4h"
queryTimeout = "100ms"
execTimeout = "100ms"
tranTimeout = "200ms"
[mysql.breaker]
window = "3s"
sleep = "100ms"
bucket = 10
ratio = 0.5
request = 100
[memcache]
name = "passport-auth-service"
proto = "tcp"
addr = ""
idle = 10
active = 10
dialTimeout = "1s"
readTimeout = "1s"
writeTimeout = "1s"
idleTimeout = "10s"
expire = "24h"
[dc]
num = 1
desc = "data center 1"
[switch]
supportOld = true

View File

@@ -0,0 +1,47 @@
# This is a TOML document. Boom.
[rpcServer2]
[[rpcServer2.servers]]
proto = "tcp"
addr = "0.0.0.0:7579"
weight = 10
[rpcServer2.zookeeper]
root = "/microservice/passport-auth-service/"
addrs = ["172.18.33.172:2181"]
timeout = "1s"
[mysql]
#addr = "172.16.33.205:3309"
#dsn = "auth:Ftqx1hwV3WoGX7Ms9udTAzmbkgR5ZHyl@tcp(172.16.33.205:3309)/passport_auth?timeout=5s&readTimeout=5s&writeTimeout=5s&parseTime=true&loc=Local&charset=utf8,utf8mb4"
addr = "127.0.0.1:3306"
dsn = "root:root@tcp(127.0.0.1:3306)/passport-auth?timeout=5s&readTimeout=5s&writeTimeout=5s&parseTime=true&loc=Local&charset=utf8,utf8mb4"
active = 5
idle = 2
IdleTimeout ="4h"
queryTimeout = "100ms"
execTimeout = "100ms"
tranTimeout = "200ms"
[mysql.breaker]
window = "3s"
sleep = "100ms"
bucket = 10
ratio = 0.5
request = 100
[Memcache]
name = "passport-auth-service"
proto = "tcp"
#addr = "172.16.33.54:11211"
addr = "127.0.0.1:11211"
idle = 1000
active = 1000
dialTimeout = "10s"
readTimeout = "10s"
writeTimeout = "10s"
idleTimeout = "30s"
[dc]
num = 1
desc = "data center 1"
[switch]
supportOld = true