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 = ["push-admin-test.toml"],
importpath = "go-common/app/admin/main/push/cmd",
tags = ["automanaged"],
deps = [
"//app/admin/main/push/conf:go_default_library",
"//app/admin/main/push/http:go_default_library",
"//app/admin/main/push/service:go_default_library",
"//library/ecode/tip:go_default_library",
"//library/log:go_default_library",
"//library/net/trace: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,56 @@
package main
import (
"flag"
"os"
"time"
"go-common/app/admin/main/push/conf"
"go-common/app/admin/main/push/http"
"go-common/app/admin/main/push/service"
ecode "go-common/library/ecode/tip"
"go-common/library/log"
"go-common/library/net/trace"
"go-common/library/os/signal"
"go-common/library/syscall"
)
var (
s *service.Service
)
func main() {
flag.Parse()
if err := conf.Init(); err != nil {
panic(err)
}
log.Init(conf.Conf.Log)
defer log.Close()
trace.Init(conf.Conf.Tracer)
defer trace.Close()
ecode.Init(conf.Conf.Ecode)
s = service.New(conf.Conf)
http.Init(conf.Conf, s)
log.Info("push-admin start")
signalHandler()
}
func signalHandler() {
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.SIGSTOP, syscall.SIGINT:
time.Sleep(time.Second * 2)
log.Info("get a signal %s, stop the push-admin process", si.String())
s.Close()
s.Wait()
time.Sleep(time.Second)
return
case syscall.SIGHUP:
default:
return
}
}
}

View File

@ -0,0 +1,118 @@
version = "1.0.0"
user = "nobody"
dir = "./"
family = "push-admin"
[log]
dir = "/data/log/push-admin/"
[HTTPServer]
addr = "0.0.0.0:7141"
maxListen = 1000
timeout = "10m"
readTimeout = "10m"
writeTimeout = "10m"
[httpClient]
key = "b1014d7c339a5649"
secret = "75b74b612aa792b112e6504cae44c319"
dial = "10s"
timeout = "10s"
keepAlive = "60s"
[httpClient.breaker]
window ="3s"
sleep ="100ms"
bucket = 10
ratio = 0.5
request = 100
[dpClient]
key = "17d515f7fa6324a19cfc6546d17ddca7"
secret = "eee2d709e54600ce147a4f522dc3c86e"
dial = "2s"
timeout = "30s"
keepAlive = "60s"
[dpClient.breaker]
window = "10s"
sleep = "100ms"
bucket = 10
ratio = 0.5
request = 100
[orm]
dsn = "test:test@tcp(172.16.33.205:3308)/bilibili_push?timeout=5s&readTimeout=5s&writeTimeout=5s&parseTime=true&loc=Local&charset=utf8,utf8mb4&allowNativePasswords=true"
active = 5
idle = 5
idleTimeout = "4h"
[mysql]
addr = "172.16.33.205"
dsn = "test:test@tcp(172.16.33.205:3308)/bilibili_push?timeout=1m&readTimeout=1m&writeTimeout=1m&parseTime=true&loc=Local&charset=utf8,utf8mb4&allowNativePasswords=true"
active = 10
idle = 5
queryTimeout = "1m"
execTimeout = "1m"
tranTimeout = "1m"
[mysql.breaker]
window = "3s"
sleep = "100ms"
bucket = 10
ratio = 0.5
request = 100
[wechat]
token = "GYQeuDWBbAsCNeGz"
secret = "ZKpmgINTkianyMbMixyxcPQjMCSHCDrk"
username = "wangjian"
[cfg]
mountDir = "/data/storage/"
diskFileExpireDay = 7
limitPerTask = 200000
taskGoroutines = 10
partitionsURL = "http://uat-api.bilibili.co/x/internal/v2/archive/typelist"
upimgURL = "http://uat-api.bilibili.co/x/internal/push-service/upimg"
[auth]
managerHost = "http://uat-manager.bilibili.co"
dashboardHost = "http://dashboard-mng.bilibili.co"
dashboardCaller = "manager-go"
[auth.DsHTTPClient]
key = "manager-go"
secret = "949bbb2dd3178252638c2407578bc7ad"
dial = "1s"
timeout = "1s"
keepAlive = "60s"
[auth.DsHTTPClient.breaker]
window = "3s"
sleep = "100ms"
bucket = 10
ratio = 0.5
request = 100
[auth.MaHTTPClient]
key = "f6433799dbd88751"
secret = "36f8ddb1806207fe07013ab6a77a3935"
dial = "1s"
timeout = "1s"
keepAlive = "60s"
[auth.MaHTTPClient.breaker]
window = "3s"
sleep = "100ms"
bucket = 10
ratio = 0.5
request = 100
[auth.session]
sessionIDLength = 32
cookieLifeTime = 1800
cookieName = "mng-go"
domain = ".bilibili.co"
[auth.session.Memcache]
name = "go-business/auth"
proto = "tcp"
addr = "172.16.33.54:11211"
active = 10
idle = 5
dialTimeout = "1s"
readTimeout = "1s"
writeTimeout = "1s"
idleTimeout = "80s"