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,41 @@
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 = ["block-job-test.toml"],
importpath = "go-common/app/job/main/block/cmd",
tags = ["automanaged"],
deps = [
"//app/job/main/block/conf:go_default_library",
"//app/job/main/block/http:go_default_library",
"//library/log: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"],
)

View File

@@ -0,0 +1,117 @@
[log]
dir = "/data/log/block-job"
[db]
addr = "127.0.0.1:3306"
dsn = "root:54985498@tcp(127.0.0.1:3306)/bilibili_block?timeout=200ms&readTimeout=200ms&writeTimeout=200ms&parseTime=true&loc=Local&charset=utf8,utf8mb4"
active = 20
idle = 10
idleTimeout ="4h"
queryTimeout = "1s"
execTimeout = "1s"
tranTimeout = "2s"
[db.breaker]
window = "3s"
sleep = "100ms"
bucket = 10
ratio = 0.5
request = 100
[memcache]
name = "block"
proto = "tcp"
addr = ""
idle = 5
active = 10
dialTimeout = "1s"
readTimeout = "1s"
writeTimeout = "1s"
idleTimeout = "10s"
expire = "24h"
[bm]
addr = "0.0.0.0:7551"
maxListen = 10
timeout = "1s"
[httpClient]
key = "33ac033ce123e999"
secret = "0b2847315d32989a248294e350ac3ede"
dial = "1s"
timeout = "5s"
keepAlive = "60s"
[httpClient.breaker]
window = "3s"
sleep = "100ms"
bucket = 10
ratio = 0.5
request = 100
[databus]
[databus.credit]
key = "***"
secret= "***"
group= "Credit-MainAccountLaw-S"
topic= "Credit-T"
action="sub"
name = "block-job/databus"
proto = "tcp"
addr = "127.0.0.1:6205"
idle = 2
active = 10
dialTimeout = "1s"
readTimeout = "60s"
writeTimeout = "1s"
idleTimeout = "10s"
expire = "1h"
[accountNotify]
key = "4ba46ba31f9a44ef"
secret = "99985eb4451cfb1b899ca0fbe3c4bdc8"
group = "AccountNotify-MainAccount-P"
topic = "AccountNotify-T"
action = "pub"
buffer = 128
name = "usersuit-admin/databus"
proto = "tcp"
addr = "172.16.33.158:6205"
active = 1
idle = 1
dialTimeout = "1s"
readTimeout = "1s"
writeTimeout = "1s"
idleTimeout = "10s"
[property]
limitExpireCheckLimit = 100
limitExpireCheckTick = "5m"
creditExpireCheckLimit = 100
creditExpireCheckTick = "5m"
msgURL = "http://message.bilibili.co/api/notify/send.user.notify.do"
[property.flag]
expireCheck = true # 自动解禁检查
creditSub = true # 小黑屋答题状态订阅
[property.msg]
[property.msg.blockRemove]
code = "2_3_6"
title = "账号封禁解除通知"
content = "你的账号已经解除封禁,封禁期间禁止使用的各项社区功能已经恢复。请遵守社区规范,共同维护良好的社区氛围。"
[managerLog]
Key = "2511663d546f1413"
Secret = "cde3b480836cc76df3d635470f991caa"
Group = "LogAudit-MainSearch-P"
Topic = "LogAudit-T"
Action = "pub"
Buffer = 10240
Name = "log-audit/log-sub"
Proto = "tcp"
Addr = "172.18.33.50:6205"
Active = 10
Idle = 5
DialTimeout = "200ms"
ReadTimeout = "200ms"
WriteTimeout = "200ms"
IdleTimeout = "80s"

View File

@@ -0,0 +1,46 @@
package main
import (
"flag"
"os"
"os/signal"
"syscall"
"go-common/app/job/main/block/conf"
"go-common/app/job/main/block/http"
"go-common/library/log"
manager "go-common/library/queue/databus/report"
)
func main() {
flag.Parse()
if err := conf.Init(); err != nil {
log.Error("conf.Init() err(%+v)", err)
panic(err)
}
log.Init(conf.Conf.Log)
defer log.Close()
http.Init()
// manager log init
manager.InitManager(conf.Conf.ManagerLog)
log.Info("block-job start")
signalHandler()
}
func signalHandler() {
c := make(chan os.Signal, 1)
signal.Notify(c, syscall.SIGHUP, syscall.SIGQUIT, syscall.SIGTERM, syscall.SIGINT)
for {
s := <-c
log.Info("block get a signal %s", s.String())
switch s {
case syscall.SIGQUIT, syscall.SIGTERM, syscall.SIGINT:
log.Info("block-job exit")
return
case syscall.SIGHUP:
default:
return
}
}
}