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,45 @@
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 = ["point-service.toml"],
importpath = "go-common/app/service/main/point/cmd",
tags = ["automanaged"],
visibility = ["//visibility:public"],
deps = [
"//app/service/main/point/conf:go_default_library",
"//app/service/main/point/rpc/server:go_default_library",
"//app/service/main/point/server/grpc:go_default_library",
"//app/service/main/point/server/http:go_default_library",
"//app/service/main/point/service:go_default_library",
"//library/ecode/tip:go_default_library",
"//library/log: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,61 @@
package main
import (
"context"
"flag"
"os"
"os/signal"
"syscall"
"time"
"go-common/app/service/main/point/conf"
rpc "go-common/app/service/main/point/rpc/server"
grpc "go-common/app/service/main/point/server/grpc"
"go-common/app/service/main/point/server/http"
"go-common/app/service/main/point/service"
ecode "go-common/library/ecode/tip"
"go-common/library/log"
)
var svc *service.Service
func main() {
flag.Parse()
if err := conf.Init(); err != nil {
log.Error("conf.Init() error(%v)", err)
panic(err)
}
// init log
log.Init(conf.Conf.Log)
defer log.Close()
log.Info("point start")
// ecode init
ecode.Init(conf.Conf.Ecode)
// service init
svc = service.New(conf.Conf)
// rpc init
rpcSvr := rpc.New(conf.Conf, svc)
ws := grpc.New(conf.Conf.WardenServer, svc)
// service init
http.Init(svc)
// init pprof conf.Conf.Perf
// init signal
c := make(chan os.Signal, 1)
signal.Notify(c, syscall.SIGHUP, syscall.SIGQUIT, syscall.SIGTERM, syscall.SIGINT)
for {
s := <-c
log.Info("point get a signal %s", s.String())
switch s {
case syscall.SIGQUIT, syscall.SIGTERM, syscall.SIGINT:
rpcSvr.Close()
ws.Shutdown(context.Background())
time.Sleep(time.Second * 2)
log.Info("point exit")
return
case syscall.SIGHUP:
default:
return
}
}
}

View File

@@ -0,0 +1,48 @@
[bm]
addr = "0.0.0.0:7582"
maxListen = 10
timeout = "1s"
[mysql]
addr = "127.0.0.1:3306"
dsn = "root:123456@tcp(127.0.0.1:3306)/bilibili_point?timeout=200ms&readTimeout=200ms&writeTimeout=200ms&parseTime=true&loc=Local&charset=utf8,utf8mb4"
active = 20
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 = "point"
proto = "tcp"
addr = "172.18.33.61:11241"
idle = 5
active = 10
dialTimeout = "1s"
readTimeout = "1s"
writeTimeout = "1s"
idleTimeout = "10s"
expire = "24h"
[property]
pointActiveStartDate = "2018-03-21 17:55:00"
pointActiveEndDate = "2019-01-21 20:04:05"
configLoadTick = "60s"
activityAllowAppID = [3]
pointGetRule = {"2" = 0,"3" = 50}
pointWhiteAppkeys = "ad4bb9b8f5d9d4a7"
[rpcServer]
proto = "tcp"
addr = "0.0.0.0:7589"
weight = 10
group=""