Initial commit

This commit is contained in:
Donny
2019-04-22 20:46:32 +08:00
commit 49ab8aadd1
25441 changed files with 4055000 additions and 0 deletions

View File

@@ -0,0 +1,43 @@
load(
"@io_bazel_rules_go//go:def.bzl",
"go_library",
"go_binary",
)
go_library(
name = "go_default_library",
srcs = ["main.go"],
data = ["saga-test.toml"],
importpath = "go-common/app/tool/saga/cmd",
tags = ["automanaged"],
visibility = ["//visibility:private"],
deps = [
"//app/tool/saga/conf:go_default_library",
"//app/tool/saga/http:go_default_library",
"//app/tool/saga/service: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",
],
)
go_binary(
name = "cmd",
embed = [":go_default_library"],
visibility = ["//visibility:public"],
)
filegroup(
name = "package-srcs",
srcs = glob(["**"]),
tags = ["automanaged"],
visibility = ["//visibility:private"],
)
filegroup(
name = "all-srcs",
srcs = [":package-srcs"],
tags = ["automanaged"],
visibility = ["//visibility:public"],
)

55
app/tool/saga/cmd/main.go Normal file
View File

@@ -0,0 +1,55 @@
package main
import (
"flag"
"os"
"time"
"go-common/app/tool/saga/conf"
"go-common/app/tool/saga/http"
"go-common/app/tool/saga/service"
"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()
s = service.New()
http.Init(s)
log.Info("saga (version: %s) 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:
log.Info("get a signal %s, stop the saga process", si.String())
s.Close()
s.Wait()
time.Sleep(time.Second)
return
case syscall.SIGHUP:
default:
return
}
}
}

View File

@@ -0,0 +1,185 @@
version = "5.14.1"
[log]
[bm]
addr = "0.0.0.0:7000"
timeout = "1s"
maxListen = 100
[memcache]
mrRecordExpire = "720h"
[memcache.mr]
name = "mr"
proto = "tcp"
addr = "172.18.33.130:11211"
idle = 5
active = 10
dialTimeout = "1s"
readTimeout = "1s"
writeTimeout = "1s"
idleTimeout = "80s"
[redis]
active = 100
idle = 100
idleTimeout = "3s"
waitTimeout = "3s"
wait = false
name = "redis"
proto = "tcp"
addr = "10.23.103.180:6379"
dialTimeout = "1s"
readTimeout = "1s"
writeTimeout = "1s"
[hbase]
master = ""
meta = ""
dialTimeout = "1s"
readTimeout = "1500ms"
readsTimeout = "600ms"
writeTimeout = "3000ms"
writesTimeout = "600ms"
[hbase.zookeeper]
root = ""
addrs = ["10.23.103.153:2181","172.18.33.168:2181","172.18.33.169:2181"]
timeout = "30s"
[httpClient]
key = "fakeKey"
secret = "fakeSecret"
dial = "1s"
timeout = "10s"
keepAlive = "60s"
[httpClient.breaker]
window = "3s"
sleep = "100ms"
bucket = 10
ratio = 0.5
request = 100
switchoff = false
[orm]
dsn = "root:123456@tcp(172.18.33.130:3306)/saga?timeout=200ms&readTimeout=200ms&writeTimeout=200ms&parseTime=true&loc=Local&charset=utf8,utf8mb4"
active = 5
idle = 5
idleTimeout = "4h"
[identify]
[identify.app]
key = "7c7ac0db1aa05587"
secret = "9a6d62d93290c5f771ad381e9ca23f26"
[identify.memcache]
name = "go-business/identify"
proto = "unix"
addr = "/tmp/shd-platform-identify-web-mc.sock"
active = 1024
idle = 64
dialTimeout = "30ms"
readTimeout = "70ms"
writeTimeout = "70ms"
idleTimeout = "80s"
[identify.host]
auth = "http://passport.bilibili.co"
secret = "http://open.bilibili.co"
[identify.httpClient]
key = "7c7ac0db1aa05587"
secret = "9a6d62d93290c5f771ad381e9ca23f26"
dial = "30ms"
timeout = "50ms"
keepAlive = "60s"
[identify.httpClient.breaker]
window = "3s"
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"}
[property]
taskTimeout = "1m"
codePath = "/data/code"
toolPath = "/data/tool/go/bin:/root/gopath/bin:/root/nodejs/node-v8.9.3-linux-x64/bin"
goroot = "/data/tool/go"
[property.rider]
token = "sWLFPxns"
secret = "rmIrNLqQSmUGRuFV"
buildURL = "http://ops-rider.bilibili.co/api/app/saga_build_app"
resultURL = "http://ops-rider.bilibili.co/api/app/get_build_info/%d"
retagURL = "http://ops-rider.bilibili.co/api/app/saga_retag_app"
releaseURL = "http://ops-rider.bilibili.co/api/sagarelease/start_release_app"
releaseResultURL = "http://ops-rider.bilibili.co/api/releaseset/envflow_taskstatus/%d"
pollPeriod = "5s"
[property.serviceTree]
tokenURL = "http://easyst.bilibili.co/v1/token"
infoURL = "http://easyst.bilibili.co/v1/node/tree"
username = "saga"
platformID = "VhF33E/rYfLEsJxPh/MAuyY+XR>j&$kBaQXhV@F?yufxdMyvM3"
reloadTick = "1h"
[property.dag]
buildTick = "1h"
repoURL = "git@gitlab.bilibili.co:platform/go-common.git"
repoName = "go-common"
repoGitlabName = "Kratos"
[property.gitlab]
api = "http://gitlab.bilibili.co/api/v4"
token = "z3nN4s4BVX5oNYXKbEPL"
[[property.webhooks]]
url = "http://api.bilibili.co/x/internal/v1/saga/gitlab/mr"
mergeRequestsEvents = true
[[property.webhooks]]
url = "http://api.bilibili.co/x/internal/v1/saga/gitlab/comment"
noteEvents = true
[[property.webhooks]]
url = "http://api.bilibili.co/x/internal/v1/saga/gitlab/pipeline"
pipelineEvents = true
[property.mail]
host = "smtp.exmail.qq.com"
port = 465
address = "saga@bilibili.com"
pwd = ""
name = "SAGA"
[property.ut]
rate = 0.3
[property.wechat]
appId = 1000047
appSecret = "WveODxk3xpT9box48wcxkmArx3mu6d4vJHdJkNy_iTk"
[property.contact]
appId = 9527
appSecret = "humOPReDjdLaGwIyXO1NyJIbzf09ESO2Izn40jqjBg8"
[property.healthcheck]
checkCron = "0 0 5 ? * ?"
[[property.healthcheck.alertAddrs]]
name = "HinaKaze"
address = "muyang@bilibili.com"
[property.reportrequiredvisible]
checkCron = "0 0 0 ? * 0"
[[property.reportrequiredvisible.alertAddrs]]
name = "zhanglin"
address = "zhanglin@bilibili.com"
[[property.reportrequiredvisible.alertAddrs]]
name = "fangrongchang"
address = "fangrongchang@bilibili.com"
[[property.reportrequiredvisible.alertAddrs]]
name = "tangyongqiang"
address = "tangyongqiang@bilibili.com"
[property.synccontact]
checkCron = "0 0 10 * * ?"
[[property.repos]]
url = "git@gitlab.bilibili.co:platform/go-common.git"
name = "go-common"
gName = "Kratos"
language = "go"
minReviewer= 1
IgnoreFiles = ["BUILD"]
[[property.repos]]
url = "git@gitlab.bilibili.co:zhanglin/bililive-android-livevideo-ci-test.git"
name = "bililive-android-livevideo-ci-test"
language = "android"
IgnoreFiles = ["BUILD"]