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 = [
"web-show-example.toml",
"web-show-test.toml",
],
importpath = "go-common/app/interface/main/web-show/cmd",
tags = ["automanaged"],
visibility = ["//visibility:public"],
deps = [
"//app/interface/main/web-show/conf:go_default_library",
"//app/interface/main/web-show/http:go_default_library",
"//library/log:go_default_library",
"//library/net/trace: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,46 @@
package main
import (
"flag"
"os"
"os/signal"
"syscall"
"go-common/app/interface/main/web-show/conf"
"go-common/app/interface/main/web-show/http"
"go-common/library/log"
"go-common/library/net/trace"
)
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.XLog)
trace.Init(conf.Conf.Tracer)
defer trace.Close()
defer log.Close()
log.Info("web-show start")
// service init
http.Init(conf.Conf)
// init signal
c := make(chan os.Signal, 1)
signal.Notify(c, syscall.SIGHUP, syscall.SIGQUIT, syscall.SIGTERM, syscall.SIGINT)
for {
s := <-c
log.Info("web-show get a signal %s", s.String())
switch s {
case syscall.SIGQUIT, syscall.SIGTERM, syscall.SIGINT:
http.CloseService()
log.Info("web-show exit")
return
case syscall.SIGHUP:
// TODO reload
default:
return
}
}
}

View File

@@ -0,0 +1,129 @@
# This is a TOML document. Boom.
version = "1.0.0"
user = "nobody"
pid = "/tmp/web-show.pid"
dir = "./"
perf = "0.0.0.0:6120"
checkFile = "/data/www/web-show.html"
family = "web-show"
address = "172.16.0.148"
bangumiuri = "http://bangumi.bilibili.com/api/bp"
[reload]
jobs ="1h"
notice = "300s"
ad="300s"
[app]
key = "f022126a8a365e20"
secret = "b7b86838145d634b487e67b811b8fab2"
[xlog]
dir = "/data/log/web-show/"
[xlog.elk]
project = "web-show"
addr = "172.18.20.17:8520"
chanSize = 10240
[statsd]
project = "web-show"
addr = "172.18.20.15:8200"
chanSize = 10240
[httpClient]
dial = "500ms"
timeout = "2s"
keepAlive = "60s"
timer = 1000
[httpClient.breaker]
window ="10s"
sleep ="10ms"
bucket = 10
ratio = 0.1
request = 100
[multiHTTP]
[multiHTTP.outer]
addrs = ["0.0.0.0:6121"]
maxListen = 10
[multiHTTP.inner]
addrs = ["0.0.0.0:6122"]
maxListen = 10
[multiHTTP.local]
addrs = ["0.0.0.0:6123"]
maxListen = 10
[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 = 10
dialTimeout = "1s"
readTimeout = "1s"
writeTimeout = "1s"
idleTimeout = "80s"
[identify.host]
auth = "http://passport.bilibili.com"
secret = "http://open.bilibili.com"
[identify.authHTTPClient]
dial = "1s"
timeout = "1s"
keepAlive = "60s"
timer = 1000
[identify.secretHTTPClient]
dial = "1s"
timeout = "1s"
keepAlive = "60s"
timer = 1000
[rpcClient2]
[rpcClient2.archive]
pullInterval = "10s"
[rpcClient2.archive.client]
timeout = "1s"
timer = 1000
[[rpcClient2.archive.backup]]
proto = "tcp"
addr = "127.0.0.1:6089"
timeout = "1s"
timer = 1000
[rpcClient2.archive.zookeeper]
root = "/microservice/archive-service/"
addrs = ["127.0.0.1:2181"]
timeout = "30s"
[mysql]
[mysql.operation]
addr = "172.16.0.148:3306"
dsn = "test:test@tcp(172.16.0.148:3306)/bilibili_operation?timeout=5s&readTimeout=5s&writeTimeout=5s&parseTime=true&loc=Local&charset=utf8,utf8mb4"
active = 5
idle = 2
[mysql.ads]
addr = "172.16.0.148:3306"
dsn = "test:test@tcp(172.16.0.148:3306)/bilibili_ads?timeout=5s&readTimeout=5s&writeTimeout=5s&parseTime=true&loc=Local&charset=utf8,utf8mb4"
active = 5
idle = 2
[mysql.res]
addr = "172.16.0.148:3306"
dsn = "test:test@tcp(172.16.0.148:3306)/bilibili_resource?timeout=5s&readTimeout=5s&writeTimeout=5s&parseTime=true&loc=Local&charset=utf8,utf8mb4"
active = 5
idle = 2
[mysql.crm]
addr = "172.16.0.116:3306"
dsn = "test:test@tcp(172.16.0.116:3306)/bilibili_crm?timeout=5s&readTimeout=5s&writeTimeout=5s&parseTime=true&loc=Local&charset=utf8,utf8mb4"
active = 5
idle = 2
[tracer]
proto = "udp"
addr = "172.16.33.46:5140"
tag = "platform/web-show"

View File

@@ -0,0 +1,205 @@
# This is a TOML document. Boom.
version = "1.0.0"
user = "nobody"
pid = "/tmp/web-show.pid"
dir = "./"
perf = "0.0.0.0:6120"
checkFile = "/data/www/web-show.html"
family = "web-show"
address = "172.16.0.148"
static = "/data/conf/web-show/static"
[Host]
bangumi = "http://bangumi.bilibili.com"
ad = "http://ad.bilibili.co"
[routerconfig]
[routerconfig.degrade]
on = false
args = ["ids"]
[reload]
jobs ="300s"
notice = "300s"
ad="10s"
[app]
key = "f022126a8a365e20"
secret = "b7b86838145d634b487e67b811b8fab2"
[xlog]
dir = "/data/log/web-show/"
[xlog.elk]
project = "web-show"
addr = "172.18.20.17:8520"
chanSize = 10240
[statsd]
project = "web-show"
addr = "172.18.20.15:8200"
chanSize = 10240
[httpClient]
dial = "500ms"
timeout = "100ms"
keepAlive = "60s"
key = "f022126a8a365e20"
secret = "b7b86838145d634b487e67b811b8fab2"
timer = 1000
[httpClient.breaker]
window ="10s"
sleep ="10ms"
bucket = 10
ratio = 0.1
request = 10
[multiHTTP]
[multiHTTP.outer]
addrs = ["0.0.0.0:6121"]
maxListen = 100
[multiHTTP.inner]
addrs = ["0.0.0.0:6122"]
maxListen = 10
[multiHTTP.local]
addrs = ["0.0.0.0:6123"]
maxListen = 10
[bm]
[bm.outer]
addr = "0.0.0.0:6121"
maxListen = 100
timeout = "1s"
[bm.inner]
addr = "0.0.0.0:6122"
maxListen = 10
timeout = "1s"
[bm.local]
addr = "0.0.0.0:6123"
maxListen = 10
timeout = "1s"
[identify]
whiteAccessKey = ""
whiteMid = 0
[identify.app]
key = "f022126a8a365e20"
secret = "b7b86838145d634b487e67b811b8fab2"
[identify.memcache]
name = "go-business/identify"
proto = "tcp"
addr = "172.16.33.54:11211"
active = 5
idle = 10
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"}
[rpcClient2]
[rpcClient2.archive]
timeout = "30s"
[rpcClient2.account]
timeout = "30s"
[rpcClient2.resource]
timeout = "30s"
[mysql]
[mysql.operation]
addr = "172.16.33.54:3306"
dsn = "test:test@tcp(172.16.33.54:3306)/bilibili_operation?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"
[mysql.operation.breaker]
window ="3s"
sleep ="100ms"
bucket = 10
ratio = 0.5
request = 100
[mysql.ads]
addr = "172.16.33.54:3306"
dsn = "test:test@tcp(172.16.33.54:3306)/bilibili_ads?timeout=5s&readTimeout=5s&writeTimeout=5s&parseTime=true&loc=Local&charset=utf8,utf8mb4"
active = 5
idle = 2
idleTimeout ="4h"
queryTimeout = "500ms"
execTimeout = "500ms"
tranTimeout = "800ms"
[mysql.ads.breaker]
window ="3s"
sleep ="100ms"
bucket = 10
ratio = 0.5
request = 100
[mysql.res]
addr = "172.16.33.54:3306"
dsn = "test:test@tcp(172.16.33.54:3306)/bilibili_resource?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"
[mysql.res.breaker]
window ="3s"
sleep ="100ms"
bucket = 10
ratio = 0.5
request = 100
[mysql.cpt]
addr = "172.16.0.116:3306"
dsn = "test:test@tcp(172.16.0.116:3306)/bilibili_solar?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"
[mysql.cpt.breaker]
window ="3s"
sleep ="100ms"
bucket = 10
ratio = 0.5
request = 100
[degradeConfig]
expire = 86400
[degradeConfig.memcache]
name = "go-common/app/interface/activity/web-show"
proto = "tcp"
addr = "172.16.13.140:11211"
idle = 5
active = 10
dialTimeout = "1s"
readTimeout = "1s"
writeTimeout = "1s"
idleTimeout = "80s"
[tracer]
proto = "udp"
addr = "172.16.33.46:5140"
tag = "platform/web-show"