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,43 @@
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 = ["playlist-job-test.toml"],
importpath = "go-common/app/job/main/playlist/cmd",
tags = ["automanaged"],
visibility = ["//visibility:public"],
deps = [
"//app/job/main/playlist/conf:go_default_library",
"//app/job/main/playlist/http:go_default_library",
"//app/job/main/playlist/service: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,6 @@
#!/bin/bash
command -v goconvey >/dev/null 2>&1 || { echo >&2 "required goconvey but it's not installed."; echo "Aborting."; echo "Please run commond: go get github.com/smartystreets/goconvey"; exit 1; }
cd ../
goconvey -excludedDirs "vendor" -packages 1

View File

@@ -0,0 +1,59 @@
package main
import (
"flag"
"os"
"os/signal"
"syscall"
"time"
"go-common/app/job/main/playlist/conf"
"go-common/app/job/main/playlist/http"
"go-common/app/job/main/playlist/service"
"go-common/library/log"
"go-common/library/net/trace"
)
func main() {
flag.Parse()
initConf()
initLog()
defer log.Close()
log.Info("playlist-job start")
srv := service.New(conf.Conf)
http.Init(conf.Conf, srv)
initSignal(srv)
}
func initConf() {
if err := conf.Init(); err != nil {
panic(err)
}
}
func initLog() {
log.Init(conf.Conf.Log)
trace.Init(conf.Conf.Tracer)
defer trace.Close()
}
func initSignal(srv *service.Service) {
c := make(chan os.Signal, 1)
signal.Notify(c, syscall.SIGHUP, syscall.SIGQUIT, syscall.SIGTERM, syscall.SIGINT)
for {
s := <-c
log.Info("playlist-job get a signal: %s", s.String())
switch s {
case syscall.SIGQUIT, syscall.SIGTERM, syscall.SIGINT:
if err := srv.Close(); err != nil {
log.Error("srv close consumer error(%v)", err)
}
time.Sleep(time.Second)
return
case syscall.SIGHUP:
// TODO: reload
default:
return
}
}
}

View File

@@ -0,0 +1,140 @@
version = "1.0.0"
user = "nobody"
pid = "/tmp/playlist-job.pid"
env="dev" # dev or pro
dir = "./"
family = "playlist-job"
[log]
family = "playlist-job"
dir = "/data/log/playlist-job/"
[app]
key = "b1014d7c339a5649"
secret = "75b74b612aa792b112e6504cae44c319"
[HTTPServer]
addr = "0.0.0.0:7201"
timeout = "1s"
[HTTPClient]
key = "b1014d7c339a5649"
secret = "75b74b612aa792b112e6504cae44c319"
dial = "50ms"
timeout = "1s"
keepAlive = "60s"
[playlistViewSub]
key = "9765cdac5894f2ba"
secret = "1448f5f2cd6029f6af6c5d438cd31edd"
group = "StatView-MainWebSvr-S"
topic = "StatView-T"
action = "sub"
name = "playlist-job/playlist-sub"
proto = "tcp"
addr = "172.16.33.158:6205"
idle = 100
active = 100
dialTimeout = "1s"
readTimeout = "60s"
writeTimeout = "1s"
idleTimeout = "10s"
[playlistFavSub]
key = "9765cdac5894f2ba"
secret = "1448f5f2cd6029f6af6c5d438cd31edd"
group = "StatFav-MainWebSvr-S"
topic = "StatFav-T"
action = "sub"
name = "playlist-job/playlist-sub"
proto = "tcp"
addr = "172.16.33.158:6205"
idle = 100
active = 100
dialTimeout = "1s"
readTimeout = "60s"
writeTimeout = "1s"
idleTimeout = "10s"
[playlistReplySub]
key = "9765cdac5894f2ba"
secret = "1448f5f2cd6029f6af6c5d438cd31edd"
group = "StatReply-MainWebSvr-S"
topic = "StatReply-T"
action = "sub"
name = "playlist-job/playlist-sub"
proto = "tcp"
addr = "172.16.33.158:6205"
idle = 100
active = 100
dialTimeout = "1s"
readTimeout = "60s"
writeTimeout = "1s"
idleTimeout = "10s"
[playlistShareSub]
key = "9765cdac5894f2ba"
secret = "1448f5f2cd6029f6af6c5d438cd31edd"
group = "StatShare-MainWebSvr-S"
topic = "StatShare-T"
action = "sub"
name = "playlist-job/playlist-sub"
proto = "tcp"
addr = "172.16.33.158:6205"
idle = 100
active = 100
dialTimeout = "1s"
readTimeout = "60s"
writeTimeout = "1s"
idleTimeout = "10s"
[playlistRPC]
pullInterval = "10s"
[playlistRPC.client]
proto = "tcp"
timeout = "1s"
timer = 1000
[playlistRPC.client.breaker]
window ="10s"
sleep ="10ms"
bucket = 10
ratio = 0.5
request = 100
[playlistRPC.zookeeper]
root = "/microservice/playlist-service/"
addrs = ["172.18.33.172:2181"]
timeout = "30s"
[mysql]
addr = "172.16.33.205"
dsn = "test:test@tcp(172.16.33.205:3308)/bilibili_playlist?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.breaker]
window = "3s"
sleep = "100ms"
bucket = 10
ratio = 0.5
request = 100
[redis]
name = "playlist-job"
proto = "tcp"
addr = "172.16.33.54:6379"
idle = 10
active = 10
dialTimeout = "1s"
readTimeout = "1s"
writeTimeout = "1s"
idleTimeout = "10s"
[job]
updateDbInterval = "0m"
interceptOn = false
viewCacheTTL = "30m"