Create & Init Project...
This commit is contained in:
46
app/service/live/xuser/cmd/BUILD
Normal file
46
app/service/live/xuser/cmd/BUILD
Normal file
@ -0,0 +1,46 @@
|
||||
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 = ["test.toml"],
|
||||
importpath = "go-common/app/service/live/xuser/cmd",
|
||||
tags = ["automanaged"],
|
||||
visibility = ["//visibility:public"],
|
||||
deps = [
|
||||
"//app/service/live/xuser/conf:go_default_library",
|
||||
"//app/service/live/xuser/server/grpc:go_default_library",
|
||||
"//app/service/live/xuser/server/http:go_default_library",
|
||||
"//app/service/live/xuser/service:go_default_library",
|
||||
"//library/ecode/tip:go_default_library",
|
||||
"//library/log:go_default_library",
|
||||
"//library/net/trace:go_default_library",
|
||||
"//library/queue/databus/report: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"],
|
||||
)
|
64
app/service/live/xuser/cmd/main.go
Normal file
64
app/service/live/xuser/cmd/main.go
Normal file
@ -0,0 +1,64 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"context"
|
||||
"flag"
|
||||
"fmt"
|
||||
"go-common/app/service/live/xuser/server/grpc"
|
||||
"go-common/library/net/trace"
|
||||
"go-common/library/queue/databus/report"
|
||||
"os"
|
||||
"os/signal"
|
||||
"syscall"
|
||||
"time"
|
||||
|
||||
"go-common/app/service/live/xuser/conf"
|
||||
"go-common/app/service/live/xuser/server/http"
|
||||
"go-common/app/service/live/xuser/service"
|
||||
ecode "go-common/library/ecode/tip"
|
||||
"go-common/library/log"
|
||||
)
|
||||
|
||||
func main() {
|
||||
flag.Parse()
|
||||
if err := conf.Init(); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
log.Init(conf.Conf.Log)
|
||||
defer log.Close()
|
||||
log.Info("xuser-service start")
|
||||
if conf.TraceInit {
|
||||
trace.Init(conf.Conf.Tracer)
|
||||
defer trace.Close()
|
||||
}
|
||||
report.InitUser(conf.Conf.Report)
|
||||
ecode.Init(conf.Conf.Ecode)
|
||||
svc := service.New(conf.Conf)
|
||||
http.Init(conf.Conf, svc)
|
||||
|
||||
// start grpc server
|
||||
svr, err := grpc.New(svc)
|
||||
if err != nil {
|
||||
panic(fmt.Sprintf("start xuser grpc server fail! %s", err))
|
||||
}
|
||||
|
||||
c := make(chan os.Signal, 1)
|
||||
signal.Notify(c, syscall.SIGHUP, syscall.SIGQUIT, syscall.SIGTERM, syscall.SIGINT)
|
||||
for {
|
||||
s := <-c
|
||||
log.Info("get a signal %s", s.String())
|
||||
switch s {
|
||||
case syscall.SIGQUIT, syscall.SIGTERM, syscall.SIGINT:
|
||||
svc.Close()
|
||||
if svr != nil {
|
||||
svr.Shutdown(context.Background())
|
||||
}
|
||||
log.Info("xuser-service exit")
|
||||
time.Sleep(time.Second)
|
||||
return
|
||||
case syscall.SIGHUP:
|
||||
default:
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
183
app/service/live/xuser/cmd/test.toml
Normal file
183
app/service/live/xuser/cmd/test.toml
Normal file
@ -0,0 +1,183 @@
|
||||
[log]
|
||||
stdout=true
|
||||
|
||||
[liveUserMysql]
|
||||
addr = "172.16.38.117:3312"
|
||||
dsn = "live:oWni@ElNs0P0C(dphdj*F1y4@tcp(172.16.38.117:3312)/live-user?timeout=5s&readTimeout=5s&writeTimeout=5s&parseTime=true&loc=Local&charset=utf8,utf8mb4"
|
||||
readDSN = ["live:oWni@ElNs0P0C(dphdj*F1y4@tcp(172.16.38.117:3312)/live-user?timeout=5s&readTimeout=5s&writeTimeout=5s&parseTime=true&loc=Local&charset=utf8,utf8mb4"]
|
||||
active = 20
|
||||
idle = 10
|
||||
idleTimeout ="4h"
|
||||
queryTimeout = "5s"
|
||||
execTimeout = "5s"
|
||||
tranTimeout = "5s"
|
||||
|
||||
[UserExpMySQL]
|
||||
addr = "172.22.34.101:3312"
|
||||
dsn = "livetestuat:livetestuat20180711/live_user_exp?timeout=2s&readTimeout=2s&writeTimeout=2s&parseTime=true&loc=Local&charset=utf8,utf8mb4"
|
||||
readDSN = ["livetestuat:livetestuat20180711@tcp(172.22.34.101:3312)/live_user_exp?timeout=2s&readTimeout=2s&writeTimeout=2s&parseTime=true&loc=Local&charset=utf8,utf8mb4"]
|
||||
active = 20
|
||||
idle = 10
|
||||
idleTimeout ="4h"
|
||||
queryTimeout = "2s"
|
||||
execTimeout = "2s"
|
||||
tranTimeout = "5s"
|
||||
|
||||
|
||||
[ExpMemcache]
|
||||
name = "xuser-service"
|
||||
proto = "tcp"
|
||||
addr = "172.18.33.82:11211"
|
||||
active = 50
|
||||
idle = 10
|
||||
dialTimeout = "1s"
|
||||
readTimeout = "1s"
|
||||
writeTimeout = "1s"
|
||||
idleTimeout = "10s"
|
||||
expire = "24h"
|
||||
|
||||
[Switch]
|
||||
QueryExp = 1
|
||||
|
||||
[UserExpExpire]
|
||||
ExpireTime = 86400
|
||||
|
||||
|
||||
[vipRedis]
|
||||
name = "xuser-vip-redis"
|
||||
proto = "tcp"
|
||||
addr = "127.0.0.1:6379"
|
||||
idle = 10
|
||||
active = 10
|
||||
dialTimeout = "1s"
|
||||
readTimeout = "1s"
|
||||
writeTimeout = "1s"
|
||||
idleTimeout = "10s"
|
||||
expire = "1m"
|
||||
|
||||
[guardRedis]
|
||||
name = "xuser-vip-redis"
|
||||
proto = "tcp"
|
||||
addr = "127.0.0.1:6379"
|
||||
idle = 10
|
||||
active = 10
|
||||
dialTimeout = "1s"
|
||||
readTimeout = "1s"
|
||||
writeTimeout = "1s"
|
||||
idleTimeout = "10s"
|
||||
expire = "1m"
|
||||
|
||||
[bmClient]
|
||||
key = "837f620f5c0a8010"
|
||||
secret = "2a9057021014b4b843b635664c69d5df"
|
||||
dial = "500ms"
|
||||
timeout = "1s"
|
||||
keepAlive = "60s"
|
||||
[httpClient.breaker]
|
||||
window = "3s"
|
||||
sleep = "100ms"
|
||||
bucket = 10
|
||||
ratio = 0.5
|
||||
request = 100
|
||||
|
||||
[liveRPC]
|
||||
[liverpc.room]
|
||||
AppID = "live.room"
|
||||
ConnTimeout = "50ms"
|
||||
Addr = "172.18.33.82:20200"
|
||||
|
||||
[liverpc.user]
|
||||
AppID = "live.user"
|
||||
ConnTimeout = "50ms"
|
||||
Addr = "172.18.33.82:20802"
|
||||
|
||||
[liverpc.banned]
|
||||
AppID = "live.banned"
|
||||
ConnTimeout = "50ms"
|
||||
Addr = "172.18.33.82:20822"
|
||||
|
||||
[liverpc.fans_medal]
|
||||
AppID = "live.fansmedal"
|
||||
ConnTimeout = "50ms"
|
||||
Addr = "172.18.33.82:20800"
|
||||
|
||||
|
||||
[liveVipChangePub]
|
||||
key = "ec4c0820d525d67b"
|
||||
secret = "2bdf3bd4ecab041b5d5640a1da4f7f81"
|
||||
group = "LiveVipChange-LiveLive-P"
|
||||
topic = "LiveVipChange-T"
|
||||
action = "pub"
|
||||
buffer = 128
|
||||
name = "xuser-vip/databus"
|
||||
proto = "tcp"
|
||||
addr = "172.16.33.158:6205"
|
||||
active = 1
|
||||
idle = 1
|
||||
dialTimeout = "1s"
|
||||
readTimeout = "1s"
|
||||
writeTimeout = "1s"
|
||||
idleTimeout = "10s"
|
||||
|
||||
[liveEntryEffectPub]
|
||||
key = "ec4c0820d525d67b"
|
||||
secret = "e20f8f664bf10722efeb6aac0cc16011"
|
||||
group = "LiveEntryEffect-LiveLive-P"
|
||||
topic = "LiveEntryEffect-T"
|
||||
action = "pub"
|
||||
buffer = 128
|
||||
name = "xuser-guard/databus"
|
||||
proto = "tcp"
|
||||
addr = "172.18.33.50:6205"
|
||||
active = 1
|
||||
idle = 1
|
||||
dialTimeout = "1s"
|
||||
readTimeout = "1s"
|
||||
writeTimeout = "1s"
|
||||
idleTimeout = "10s"
|
||||
|
||||
[liveAppMySQL]
|
||||
addr = "172.22.34.101:3312"
|
||||
dsn = "livetestuat:livetestuat20180711@tcp(172.22.34.101:3312)/live-app?timeout=2s&readTimeout=2s&writeTimeout=2s&parseTime=true&loc=Local&charset=utf8,utf8mb4"
|
||||
readDSN = ["live:livetestuat20180711@tcp(172.22.34.101:3312)/live-app?timeout=2s&readTimeout=2s&writeTimeout=2s&parseTime=true&loc=Local&charset=utf8,utf8mb4"]
|
||||
active = 20
|
||||
idle = 10
|
||||
idleTimeout ="4h"
|
||||
queryTimeout = "2s"
|
||||
execTimeout = "2s"
|
||||
tranTimeout = "5s"
|
||||
|
||||
[liveAppORM]
|
||||
addr = "172.22.34.101:3312"
|
||||
dsn = "livetestuat:livetestuat20180711@tcp(172.22.34.101:3312)/live-app?timeout=2s&readTimeout=2s&writeTimeout=2s&parseTime=true&loc=Local&charset=utf8,utf8mb4"
|
||||
readDSN = ["live:livetestuat20180711@tcp(172.22.34.101:3312)/live-app?timeout=2s&readTimeout=2s&writeTimeout=2s&parseTime=true&loc=Local&charset=utf8,utf8mb4"]
|
||||
active = 20
|
||||
idle = 10
|
||||
idleTimeout ="4h"
|
||||
queryTimeout = "2s"
|
||||
execTimeout = "2s"
|
||||
tranTimeout = "5s"
|
||||
|
||||
[redis]
|
||||
name = "xuser-redis"
|
||||
proto = "tcp"
|
||||
addr = "127.0.0.1:6379"
|
||||
idle = 10
|
||||
active = 10
|
||||
dialTimeout = "1s"
|
||||
readTimeout = "1s"
|
||||
writeTimeout = "1s"
|
||||
idleTimeout = "10s"
|
||||
expire = "1m"
|
||||
|
||||
[memcache]
|
||||
name = "xuser-memcache"
|
||||
proto = "tcp"
|
||||
addr = "127.0.0.1:11211"
|
||||
active = 50
|
||||
idle = 10
|
||||
dialTimeout = "1s"
|
||||
readTimeout = "1s"
|
||||
writeTimeout = "1s"
|
||||
idleTimeout = "10s"
|
||||
expire = "24h"
|
Reference in New Issue
Block a user