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,46 @@
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-service-test.toml"],
importpath = "go-common/app/service/main/push/cmd",
tags = ["automanaged"],
visibility = ["//visibility:public"],
deps = [
"//app/service/main/push/conf:go_default_library",
"//app/service/main/push/server/gorpc:go_default_library",
"//app/service/main/push/server/grpc:go_default_library",
"//app/service/main/push/server/http:go_default_library",
"//app/service/main/push/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,55 @@
package main
import (
"context"
"flag"
"os"
"os/signal"
"syscall"
"time"
"go-common/app/service/main/push/conf"
pushrpc "go-common/app/service/main/push/server/gorpc"
"go-common/app/service/main/push/server/grpc"
"go-common/app/service/main/push/server/http"
"go-common/app/service/main/push/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)
trace.Init(conf.Conf.Tracer)
defer trace.Close()
defer log.Close()
log.Info("push-service start")
ecode.Init(conf.Conf.Ecode)
svr := service.New(conf.Conf)
rpcSrv := pushrpc.New(conf.Conf, svr)
grpcSvr := grpc.New(conf.Conf.GRPC, svr)
http.Init(conf.Conf, svr)
c := make(chan os.Signal, 1)
signal.Notify(c, syscall.SIGHUP, syscall.SIGQUIT, syscall.SIGTERM, syscall.SIGINT)
for {
s := <-c
log.Info("push-service get a signal %s", s.String())
switch s {
case syscall.SIGQUIT, syscall.SIGTERM, syscall.SIGSTOP, syscall.SIGINT:
rpcSrv.Close()
grpcSvr.Shutdown(context.Background())
svr.Close()
log.Info("push-service exit")
time.Sleep(time.Second)
return
case syscall.SIGHUP:
default:
return
}
}
}

View File

@@ -0,0 +1,152 @@
version = "1.0.0"
user = "nobody"
pid = "/tmp/push-service.pid"
dir = "./"
family = "push-service"
[log]
dir = "/data/log/push-service/"
[rpcServer]
proto = "tcp"
addr = "0.0.0.0:7779"
[grpc]
timeout = "1s"
addr = "0.0.0.0:9000"
[HTTPServer]
addr = "0.0.0.0:7771"
maxListen = 1000
timeout = "1s"
readTimeout = "1s"
writeTimeout = "1s"
[HTTPClient]
dial = "50ms"
timeout = "200ms"
keepAlive = "60s"
key = "f265dcfa28272742"
secret = "437facc22dc8698b5544669bcc12348d"
[HTTPClient.breaker]
window ="1s"
sleep ="10ms"
bucket = 10
ratio = 0.5
request = 100
[apns]
poolSize = 200
proxy = 0 # 0表示不使用代理
proxySocket = "133.130.49.92:9091"
timeout = "10s"
[android]
poolSize = 50
timeout = "30s"
pushHuaweiPart = 30
miUseVip = 0
[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"
active = 10
idle = 5
queryTimeout = "1m"
execTimeout = "1m"
tranTimeout = "1m"
[mysql.breaker]
window = "3s"
sleep = "100ms"
bucket = 10
ratio = 0.5
request = 100
[redis]
name = "push-service"
proto = "tcp"
addr = "172.16.33.54:6379"
idle = 1000
active = 10000
dialTimeout = "10s"
readTimeout = "10s"
writeTimeout = "10s"
idleTimeout = "30s"
tokenExpire = "72h"
laterExpire = "72h"
midsExpire = "72h"
[memcache]
name = "push-service"
proto = "tcp"
addr = "172.18.33.60:11228"
idle = 1000
active = 1000
dialTimeout = "10s"
readTimeout = "10s"
writeTimeout = "10s"
idleTimeout = "30s"
settingExpire = "720h"
reportExpire = "720h"
uuidExpire = "30m"
[reportPub]
key = "0QEO9F8JuuIxZzNDvklH"
secret="0QEO9F8JuuIxZzNDvklI"
group= "PushReport-Push-P"
topic= "PushReport-T"
action="pub"
name = "push-report-pub"
proto = "tcp"
addr = "172.16.33.158:6205"
idle = 100
active = 100
dialTimeout = "1s"
readTimeout = "60s"
writeTimeout = "1s"
idleTimeout = "10s"
[callbackPub]
key = "dbe67e6a4c36f877"
secret="6e6eb74cc73f2c8bff02fb40ee57da59"
group= "PushCallback-MainCommonArch-P"
topic= "PushCallback-T"
action="pub"
name = "push-callback-pub"
proto = "tcp"
addr = "172.16.33.158:6205"
idle = 100
active = 100
dialTimeout = "1s"
readTimeout = "60s"
writeTimeout = "1s"
idleTimeout = "10s"
[push]
pickUpTask = true
loadBusinessInteval = "5m"
loadTaskInteval = "1s"
updateTaskProgressInteval = "5s"
pushChanSizeAPNS = 10000
pushGoroutinesAPNS = 1000
pushChanSizeMi = 10000
pushGoroutinesMi = 100
pushChanSizeHuawei = 10000
pushGoroutinesHuawei = 100
pushChanSizeOppo = 10000
pushGoroutinesOppo = 100
pushChanSizeJpush = 10000
pushGoroutinesJpush = 100
pushChanSizeFCM = 10000
pushGoroutinesFCM = 100
passThrough = 1
retryTimes = 3
pushPartInterval = "1s"
pushPartChanSize = 10
pushPartSize = 1000
callbackSize = 3 # callback 聚合数
callbackChanLen = 1024000
callbackGoroutines = 10
upimgURL = "http://uat-api.bilibili.co/x/internal/upload/admin/image"
upimgMaxSize = 1048576 # 允许上传的最大图片 字节数
updateTaskProgressProc = 10