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,44 @@
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 = ["spy-admin-test.toml"],
importpath = "go-common/app/admin/main/spy/cmd",
tags = ["automanaged"],
visibility = ["//visibility:public"],
deps = [
"//app/admin/main/spy/conf:go_default_library",
"//app/admin/main/spy/http:go_default_library",
"//app/admin/main/spy/service:go_default_library",
"//library/log:go_default_library",
"//library/os/signal:go_default_library",
"//library/syscall: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 (
"flag"
"os"
"time"
"go-common/app/admin/main/spy/conf"
"go-common/app/admin/main/spy/http"
"go-common/app/admin/main/spy/service"
"go-common/library/log"
"go-common/library/os/signal"
"go-common/library/syscall"
)
var (
s *service.Service
)
func main() {
flag.Parse()
if err := conf.Init(); err != nil {
log.Error("conf.Init() error(%v)", err)
panic(err)
}
log.Init(conf.Conf.Log)
defer log.Close()
// service init
http.Init(conf.Conf)
log.Info("spy-admin start")
signalHandler()
}
func signalHandler() {
var (
ch = make(chan os.Signal, 1)
)
signal.Notify(ch, syscall.SIGHUP, syscall.SIGQUIT, syscall.SIGTERM, syscall.SIGINT, syscall.SIGSTOP)
for {
si := <-ch
switch si {
case syscall.SIGQUIT, syscall.SIGTERM, syscall.SIGSTOP, syscall.SIGINT:
time.Sleep(time.Second * 2)
log.Info("get a signal %s, stop the spy-admin process", si.String())
s.Wait()
time.Sleep(time.Second)
return
case syscall.SIGHUP:
default:
return
}
}
}

View File

@@ -0,0 +1,137 @@
version = "1.0.0"
user = "nobody"
dir = "./"
perf = "0.0.0.0:6330"
family = "spy-admin"
env = "qa"
[log]
dir = "/data/log/spy-admin/"
[db]
[db.spy]
addr= "localhost:3306"
dsn = "root:123456@tcp(localhost:3306)/bilibili_spy?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"
[db.spy.breaker]
window = "3s"
sleep = "100ms"
bucket = 10
ratio = 0.5
request = 100
[accountRPC]
pullInterval = "10s"
group = "groupapp"
[accountRPC.client]
timeout = "1s"
timer = 1000
[accountRPC.zookeeper]
root = "/microservice/account-service/"
addrs = ["172.16.33.169:2181"]
timeout = "30s"
[accountRPC.client.breaker]
window ="3s"
sleep ="100ms"
bucket = 10
ratio = 0.5
request = 100
[spyRPC]
policy = "sharding"
pullInterval = "10s"
[spyRPC.client]
timeout = "1s"
timer = 1000
[spyRPC.client.breaker]
window ="3s"
sleep ="100ms"
bucket = 10
ratio = 0.5
request = 100
[spyRPC.zookeeper]
root = "/microservice/spy-service/"
addrs = ["172.16.33.169:2181"]
timeout = "1s"
[memcache]
userExpire = "24h"
[memcache.user]
name = "spy-admin/user"
proto = "tcp"
addr = "172.16.33.22:21211"
idle = 5
active = 10
dialTimeout = "1s"
readTimeout = "1s"
writeTimeout = "1s"
idleTimeout = "10s"
[property]
telValidateURL = "http://passport.bilibili.co/intranet/acc/validateTel?"
blockAccountURL = "https://account.bilibili.com/api/member/blockAccount?"
userInfoShard = 100
historyShard = 100
loadEventTick = "60s"
[property.score]
baseInit = 100
eventInit = 100
[property.punishment]
scoreThreshold = 30
times = 3
[property.event]
serviceName = "spy_service"
bindMailAndTelLowRisk = "bind_mail_and_tel_low_risk"
bindMailOnly = "bind_mail_only"
bindNothing = "bind_nothing"
bindTelLowRiskOnly = "bind_tel_low_risk_only"
bindTelMediumRisk = "bind_tel_medium_risk"
bindTelHighRisk = "bind_tel_high_risk"
bindTelUnknownRisk = "bind_tel_unknown_risk"
[identify]
WhiteAccessKey = ""
WhiteMid = 0
[identify.app]
key = "e7482d29be4a95b8"
secret = "9e803791cdef756e75faee68e12b7442"
[identify.memcache]
name = "go-business/identify"
proto = "unix"
addr = "/tmp/platform-identify-mc.sock"
active = 5
idle = 5
dialTimeout = "1s"
readTimeout = "1s"
writeTimeout = "1s"
idleTimeout = "80s"
[identify.host]
auth = "http://passport.bilibili.com"
secret = "http://open.bilibili.com"
[identify.httpClient]
key = "53e2fa226f5ad348"
secret = "3cf6bd1b0ff671021da5f424fea4b04a"
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"}
[bm]
addr = "0.0.0.0:7581"
maxListen = 10
timeout = "1s"