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 = [
"archive-job-example.toml",
"archive-job-kisjd-test.toml",
],
importpath = "go-common/app/job/main/archive-shjd/cmd",
tags = ["automanaged"],
visibility = ["//visibility:public"],
deps = [
"//app/job/main/archive-shjd/conf:go_default_library",
"//app/job/main/archive-shjd/http:go_default_library",
"//app/job/main/archive-shjd/service: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,77 @@
version = "1.0.0"
user = "nobody"
pid = "/tmp/archive-job.pid"
dir = "./"
perf = "127.0.0.1:6161"
trace = false
debug = false
env = "test"
tick = "50ms"
[xlog]
dir = "/data/log/archive-job/"
[app]
key = "e7482d29be4a95b8"
secret = "9e803791cdef756e75faee68e12b7442"
[host]
apiCo = "http://api.bilibili.co"
[httpClient]
dial = "100ms"
timeout = "1s"
keepAlive = "60s"
timer = 128
[databus]
key = "0Pub71WwEMKXu63qtztu"
secret = "0Pub71WwEMKXu63qtztv"
group = "Stat-UGC-S"
topic = "Stat-T"
action = "sub"
[databus.redis]
name = "archive-job/databus"
proto = "tcp"
addr = "172.16.33.56:6205"
idle = 100
active = 100
dialTimeout = "1s"
readTimeout = "60s"
writeTimeout = "1s"
idleTimeout = "10s"
[kafka]
group = "archive-job-consumer"
topics = ["archive-push", "stat"]
offset = false
[kafka.zookeeper]
root = "/kafka"
addrs = ["172.16.0.148:2181"]
timeout = "30s"
[archiveRPC]
pullInterval = "10s"
[archiveRPC.client]
proto = "tcp"
addr = "172.16.0.26:6089"
timeout = "1s"
timer = 1000
[[archiveRPC.backup]]
proto = "tcp"
addr = "172.16.0.26:6089"
timeout = "1s"
timer = 1000
[archiveRPC.zookeeper]
root = "/microservice/archive-service/"
addrs = ["172.16.0.148:2181"]
timeout = "30s"
[mail]
host = "smtp.exmail.qq.com"
port = 465
username = "2333@bilibili.com"
password = "2333"
bangumi = ["233@bilibili.com"]
movie = ["233@bilibili.com"]

View File

@@ -0,0 +1,161 @@
[Redis]
name = "archive-job/track"
proto = "unix"
addr = "/tmp/shjd-archive-service-group1-redis.sock"
active = 1000
idle = 20
dialTimeout = "80ms"
readTimeout = "200ms"
writeTimeout = "200ms"
idleTimeout = "80s"
[Databus]
key = "8e27ab7e39270b59"
secret = "4b8c2e03c48f0b21eacd7a11e2a3b003"
group = "ArcResult-SHJD-MainAppSvr-S"
topic = "ArcResult-SHJD-T"
action = "sub"
name = "stat-job/databus"
proto = "tcp"
addr = "172.18.21.41:6205"
idle = 1
active = 1
dialTimeout = "1s"
readTimeout = "60s"
writeTimeout = "1s"
idleTimeout = "10s"
[ViewSub]
key = "8e27ab7e39270b59"
secret = "4b8c2e03c48f0b21eacd7a11e2a3b003"
group = "StatView-MainAppSvr-SHJD-S"
topic = "StatView-T"
action = "sub"
name = "stat-job/view"
proto = "tcp"
addr = "172.18.21.41:6205"
idle = 1
active = 1
dialTimeout = "1s"
readTimeout = "60s"
writeTimeout = "1s"
idleTimeout = "10s"
[DmSub]
key = "8e27ab7e39270b59"
secret = "4b8c2e03c48f0b21eacd7a11e2a3b003"
group = "StatDM-MainAppSvr-SHJD-S"
topic = "StatDM-T"
action = "sub"
name = "stat-job/dm"
proto = "tcp"
addr = "172.18.21.41:6205"
idle = 1
active = 1
dialTimeout = "1s"
readTimeout = "60s"
writeTimeout = "1s"
idleTimeout = "10s"
[ReplySub]
key = "8e27ab7e39270b59"
secret = "4b8c2e03c48f0b21eacd7a11e2a3b003"
group = "StatReply-MainAppSvr-SHJD-S"
topic = "StatReply-T"
action = "sub"
name = "stat-job/reply"
proto = "tcp"
addr = "172.18.21.41:6205"
idle = 1
active = 1
dialTimeout = "1s"
readTimeout = "60s"
writeTimeout = "1s"
idleTimeout = "10s"
[FavSub]
key = "8e27ab7e39270b59"
secret = "4b8c2e03c48f0b21eacd7a11e2a3b003"
group = "StatFav-MainAppSvr-SHJD-S"
topic = "StatFav-T"
action = "sub"
name = "stat-job/fav"
proto = "tcp"
addr = "172.18.21.41:6205"
idle = 1
active = 1
dialTimeout = "1s"
readTimeout = "60s"
writeTimeout = "1s"
idleTimeout = "10s"
[CoinSub]
key = "8e27ab7e39270b59"
secret = "4b8c2e03c48f0b21eacd7a11e2a3b003"
group = "StatCoin-MainAppSvr-SHJD-S"
topic = "StatCoin-T"
action = "sub"
name = "stat-job/coin"
proto = "tcp"
addr = "172.18.21.41:6205"
idle = 1
active = 1
dialTimeout = "1s"
readTimeout = "60s"
writeTimeout = "1s"
idleTimeout = "10s"
[ShareSub]
key = "8e27ab7e39270b59"
secret = "4b8c2e03c48f0b21eacd7a11e2a3b003"
group = "StatShare-MainAppSvr-SHJD-S"
topic = "StatShare-T"
action = "sub"
name = "stat-job/share"
proto = "tcp"
addr = "172.18.21.41:6205"
idle = 1
active = 1
dialTimeout = "1s"
readTimeout = "60s"
writeTimeout = "1s"
idleTimeout = "10s"
[RankSub]
key = "8e27ab7e39270b59"
secret = "4b8c2e03c48f0b21eacd7a11e2a3b003"
group = "StatRank-MainAppSvr-SHJD-S"
topic = "StatRank-T"
action = "sub"
name = "stat-job/rank"
proto = "tcp"
addr = "172.18.21.41:6205"
idle = 1
active = 1
dialTimeout = "1s"
readTimeout = "60s"
writeTimeout = "1s"
idleTimeout = "10s"
[likeSub]
key = "8e27ab7e39270b59"
secret = "4b8c2e03c48f0b21eacd7a11e2a3b003"
group = "StatLike-MainAppSvr-SHJD-S"
topic = "StatLike-T"
action = "sub"
name = "stat-job/like"
proto = "tcp"
addr = "172.18.21.41:6205"
idle = 1
active = 1
dialTimeout = "1s"
readTimeout = "60s"
writeTimeout = "1s"
idleTimeout = "10s"
[[ArchiveRPCs]]
cluster = "group1"
zone = "sh004"
[[ArchiveRPCs]]
cluster = "group2"
zone = "sh004"

View File

@@ -0,0 +1,54 @@
package main
import (
"flag"
"os"
"os/signal"
"syscall"
"go-common/app/job/main/archive-shjd/conf"
"go-common/app/job/main/archive-shjd/http"
"go-common/app/job/main/archive-shjd/service"
"go-common/library/log"
)
var (
srv *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("archive-kisjd-job start")
srv = service.New(conf.Conf)
http.Init(conf.Conf, srv)
signalHandler()
}
func signalHandler() {
var (
err error
ch = make(chan os.Signal, 1)
)
signal.Notify(ch, syscall.SIGHUP, syscall.SIGQUIT, syscall.SIGTERM, syscall.SIGINT)
for {
si := <-ch
switch si {
case syscall.SIGQUIT, syscall.SIGTERM, syscall.SIGINT:
log.Info("get a signal %s, stop the consume process", si.String())
if err = srv.Close(); err != nil {
log.Error("srv close consumer error(%v)", err)
}
return
case syscall.SIGHUP:
default:
return
}
}
}