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,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 = ["coupon-service.toml"],
importpath = "go-common/app/service/main/coupon/cmd",
tags = ["automanaged"],
visibility = ["//visibility:public"],
deps = [
"//app/service/main/coupon/conf:go_default_library",
"//app/service/main/coupon/http:go_default_library",
"//app/service/main/coupon/rpc/server:go_default_library",
"//app/service/main/coupon/server/grpc:go_default_library",
"//app/service/main/coupon/service:go_default_library",
"//library/ecode/tip:go_default_library",
"//library/log:go_default_library",
"//library/net/rpc: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,163 @@
# This is a TOML document. Boom
version = "1.0.0"
user = "nobody"
pid = "/tmp/coupon.pid"
dir = "./"
[log]
stdout = true
[bm]
timeout = "1s"
[property]
messageURL = "http://message.bilibili.com"
captchaBID = "account"
captchaTokenURL = "http://api.bilibili.co/x/internal/v1/captcha/token"
captchaVerifyURL = "http://api.bilibili.co/x/internal/v1/captcha/verify"
[platform]
1 = "iPhone"
# 2 = "iPad"
# 3 = "网页"
# 4 = "Android"
# 5 = "iPad HD"
# 6 = "iOS概念版"
# 7 = "安卓概念版"
# 8 = "微信公众号"
# 9 = "赠送好友"
[identify]
whiteAccessKey = ""
whiteMid = 0
[identify.app]
key = "6a29f8ed87407c11"
secret = "d3c5a85f5b895a03735b5d20a273bc57"
[identify.memcache]
name = "go-business/identify"
proto = "tcp"
addr = "172.16.33.54:11211"
active = 5
idle = 3
dialTimeout = "1s"
readTimeout = "1s"
writeTimeout = "1s"
idleTimeout = "80s"
[identify.host]
auth = "http://passport.bilibili.com"
secret = "http://open.bilibili.com"
[identify.httpClient]
key = "f022126a8a365e20"
secret = "b7b86838145d634b487e67b811b8fab2"
dial = "30ms"
timeout = "100ms"
keepAlive = "60s"
[identify.httpClient.breaker]
window = "10s"
sleep = "100ms"
bucket = 10
ratio = 0.5
request = 100
[identify.httpClient.url]
"http://passport.bilibili.co/intranet/auth/tokenInfo" = {timeout = "100ms"}
"http://passport.bilibili.co/intranet/auth/cookieInfo" = {timeout = "100ms"}
"http://open.bilibili.co/api/getsecret" = {timeout = "500ms"}
[mysql]
addr = "127.0.0.1:3306"
dsn = "root:123456@tcp(127.0.0.1:3306)/bilibili_coupon?timeout=2s&readTimeout=2s&writeTimeout=2s&parseTime=true&loc=Local&charset=utf8,utf8mb4"
active = 20
idle = 10
idleTimeout ="4h"
queryTimeout = "1s"
execTimeout = "1s"
tranTimeout = "2s"
[mysql.breaker]
window = "3s"
sleep = "100ms"
bucket = 10
ratio = 0.5
request = 100
[vipMysql]
addr = "172.16.33.205"
dsn = "zhaozhihao:MN9havOfnzY3kd6L78IVucRxgywe0p2P@tcp(172.16.33.205:3308)/bilibili_vip?timeout=5s&readTimeout=5s&writeTimeout=5s&parseTime=true&loc=Local&charset=utf8,utf8mb4"
active = 5
idle = 5
IdleTimeout ="4h"
QueryTimeout = "5s"
ExecTimeout = "5s"
TranTimeout = "5s"
[vipMysql.breaker]
window = "3s"
sleep = "100ms"
bucket = 10
ratio = 0.5
request = 100
[memcache]
name = "coupon"
proto = "tcp"
addr = "172.18.33.60:11237"
idle = 5
active = 10
dialTimeout = "1s"
readTimeout = "1s"
writeTimeout = "1s"
idleTimeout = "10s"
expire = "24h"
prizeExpire = "30h"
[rpcServer]
proto = "tcp"
addr = "0.0.0.0:6869"
weight = 10
[httpClient]
key = "f022126a8a365e20"
secret = "b7b86838145d634b487e67b811b8fab2"
dial = "30ms"
timeout = "300ms"
keepAlive = "60s"
[httpClient.breaker]
window = "10s"
sleep = "100ms"
bucket = 10
ratio = 0.5
request = 100
[vipinfoRPC]
timeout = "3s"
[newYearConf]
# 活动id
actID = 1
# 2019年1月1日00:00:00
startTime = 1545797400
# 2019年1月14日23:59:59
endTime = 1545883800
# 随机
randNum = 5
# 历史从未充值过大会员
noVipBatchToken1 = "210957721620181224153121"
noVipBatchToken3 = "850691829320181224153235"
noVipBatchToken12 = "798157449920181224153338"
# 年度大会员且还有180天以上才到期
more180BatchToken1 = "763272400820181225165235"
more180BatchToken3 = "947668794420181225165208"
more180BatchToken12 = "115331401920181225165136"
# 年度大会员且还有180天(含)以内才到期
less180BatchToken1 = "234526007120181224153625"
less180BatchToken3 = "231042916920181224153654"
less180BatchToken12 = "862417541120181224153722"
# 月度会员(包括连续包月)& 大会员过期
monthBatchToken1 = "360059523020181224153817"
monthBatchToken3 = "425909138520181224153843"
monthBatchToken12 = "3557982522201812241509"
[wardenServer]
addr = "0.0.0.0:9000"
timeout = "1s"

View File

@@ -0,0 +1,65 @@
package main
import (
"context"
"flag"
"os"
"os/signal"
"syscall"
"time"
"go-common/app/service/main/coupon/conf"
"go-common/app/service/main/coupon/http"
rpc "go-common/app/service/main/coupon/rpc/server"
grpc "go-common/app/service/main/coupon/server/grpc"
"go-common/app/service/main/coupon/service"
ecode "go-common/library/ecode/tip"
"go-common/library/log"
xrpc "go-common/library/net/rpc"
)
var (
svc *service.Service
rpcSvr *xrpc.Server
)
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("coupon start")
// ecode init
ecode.Init(conf.Conf.Ecode)
// service init
svc = service.New(conf.Conf)
// rpc init
rpcSvr = rpc.New(conf.Conf, svc)
// http init
http.Init(conf.Conf, svc)
// grpc
ws := grpc.New(conf.Conf.WardenServer, 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("coupon 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 * 1)
log.Info("coupon exit")
return
case syscall.SIGHUP:
default:
return
}
}
}