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,44 @@
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-strategy-test.toml"],
importpath = "go-common/app/service/main/push-strategy/cmd",
tags = ["automanaged"],
visibility = ["//visibility:public"],
deps = [
"//app/service/main/push-strategy/conf:go_default_library",
"//app/service/main/push-strategy/http:go_default_library",
"//app/service/main/push-strategy/service:go_default_library",
"//library/ecode/tip: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,49 @@
package main
import (
"flag"
"os"
"os/signal"
"syscall"
"time"
"go-common/app/service/main/push-strategy/conf"
"go-common/app/service/main/push-strategy/http"
"go-common/app/service/main/push-strategy/service"
ecode "go-common/library/ecode/tip"
"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)
}
log.Init(conf.Conf.Log)
defer log.Close()
trace.Init(conf.Conf.Tracer)
defer trace.Close()
log.Info("push-strategystart")
ecode.Init(conf.Conf.Ecode)
srv := service.New(conf.Conf)
http.Init(conf.Conf, srv)
c := make(chan os.Signal, 1)
signal.Notify(c, syscall.SIGHUP, syscall.SIGQUIT, syscall.SIGTERM, syscall.SIGINT)
for {
s := <-c
log.Info("push-strategy get a signal %s", s.String())
switch s {
case syscall.SIGQUIT, syscall.SIGTERM, syscall.SIGSTOP, syscall.SIGINT:
srv.Close()
time.Sleep(1 * time.Second)
log.Info("push-strategyexit")
return
case syscall.SIGHUP:
// TODO reload
default:
return
}
}
}

View File

@@ -0,0 +1,88 @@
version = "1.0.0"
user = "nobody"
pid = "/tmp/push-strategy.pid"
dir = "./"
family = "push-strategy"
[log]
dir = "/data/log/push-strategy/"
[httpClient]
key = "f265dcfa28272742"
secret = "437facc22dc8698b5544669bcc12348d"
dial = "500ms"
timeout = "1s"
keepAlive = "60s"
timer = 10
[httpClient.breaker]
window = "10s"
sleep = "100ms"
bucket = 10
ratio = 0.5
request = 100
[HTTPServer]
addr = "0.0.0.0:7561"
maxListen = 1000
timeout = "1s"
readTimeout = "1s"
writeTimeout = "1s"
[mysql]
addr = "172.16.33.205"
dsn = "test:test@tcp(172.16.33.205:3308)/bilibili_push?timeout=5s&readTimeout=5s&writeTimeout=5s&parseTime=true&loc=Local&charset=utf8,utf8mb4"
active = 10
idle = 5
queryTimeout = "1s"
execTimeout = "1s"
tranTimeout = "1s"
[mysql.breaker]
window = "3s"
sleep = "100ms"
bucket = 10
ratio = 0.5
request = 100
[redis]
name = "push-strategy"
proto = "tcp"
addr = "172.18.33.60:6968"
idle = 1000
active = 10000
dialTimeout = "1s"
readTimeout = "1s"
writeTimeout = "1s"
idleTimeout = "30s"
limitDayExpire = "24h"
[memcache]
name = "push-strategy"
proto = "tcp"
addr = "172.18.33.60:11228"
idle = 1000
active = 1000
dialTimeout = "10s"
readTimeout = "10s"
writeTimeout = "10s"
idleTimeout = "30s"
uuidExpire = "30m"
cdExpire = "1h"
[wechat]
token = "GYQeuDWBbAsCNeGz"
secret = "ZKpmgINTkianyMbMixyxcPQjMCSHCDrk"
username = "xxxxxxxxyyyyyyyyyy"
[bizID]
live = 1
archive = 2
[cfg]
loadTaskInteval = "1s"
loadBusinessInteval = "5m"
loadSettingsInteval = "1m"
nasPath = "/data/storage"
limitUserPerDay = 8
handleTaskGoroutines = 100
handleMidGoroutines = 5
cacheSize = 1024000