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

43
app/job/main/up/cmd/BUILD Normal file
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 = ["up-job.toml"],
importpath = "go-common/app/job/main/up/cmd",
tags = ["automanaged"],
visibility = ["//visibility:public"],
deps = [
"//app/job/main/up/conf:go_default_library",
"//app/job/main/up/server/http: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,75 @@
[MailTemplateConf]
SignTmplTitle = """[签约Up即将到期]{{Now.Format "2006-01-02"}}"""
SignTmplContent = """
<html>
<body>
<h4>您有以下签约即将到期,请尽快去<a href="http://up-profit.bilibili.co/allowance/#/contract-manage/all-contracts">【up主CRM-签约管理】查看</a></h4>
<table border="1">
<tr>
<td>id</td>
<td></td>
<td>uid</td>
<td></td>
</tr>
{{range .}}
<tr>
<td>{{.ID}}</td>
<td>{{.Name}}</td>
<td>{{.Mid}}</td>
<td>{{.EndDate.Time.Format "2006-01-02"}}</td>
</tr>
{{end}}
</table>
</body>
</html>
"""
PayTmplTitle = """"[签约Up付款即将到期]{{Now.Format "2006-01-02"}}"""
PayTmplContent = """
<html>
<body>
<h4>您有以下付款即将到期,请尽快去<a href="http://up-profit.bilibili.co/allowance/#/contract-manage/all-contracts">【up主CRM-签约管理】查看</a></h4>
<table border=1>
<tr>
<td>id</td>
<td></td>
<td>uid</td>
<td></td>
<td></td>
</tr>
{{range .}}
<tr>
<td>{{.SignID}}</td>
<td>{{.Name}}</td>
<td>{{.Mid}}</td>
<td>{{.DueDate.Time.Format "2006-01-02"}}</td>
<td>{{printf "%.2f" .GetPayValue}}</td>
</tr>
{{end}}
</table>
</body>
</html>"""
TaskTmplTitle = """[Up]{{Now.Format "2006-01-02"}}"""
TaskTmplContent = """
<html>
<body>
up<a href="http://up-profit.bilibili.co/allowance/#/contract-manage/all-contracts">upCRM-</a>
<table border=1>
<tr>
<td>id</td>
<td></td>
<td>uid</td>
<td></td>
<td></td>
</tr>
{{range .}}
<tr>
<td>{{.SignID}}</td>
<td>{{.Name}}</td>
<td>{{.Mid}}</td>
<td>{{(.EndDate.Time.AddDate 0 0 -1).Format "2006-01-02"}}</td>
<td>{{(printf "%s投稿 %d/%d" .TypeDesc .TaskCounter .TaskCondition)}}</td>
</tr>
{{end}}
</table>
</body>
</html>"""

View File

@@ -0,0 +1,43 @@
package main
import (
"flag"
"os"
"os/signal"
"syscall"
"go-common/app/job/main/up/conf"
"go-common/app/job/main/up/server/http"
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 {
panic(err)
}
log.Init(conf.Conf.Log)
log.SetFormat("[%D %T] [%L] [%S] %M")
defer log.Close()
log.Info("server start")
trace.Init(conf.Conf.Tracer)
defer trace.Close()
ecode.Init(conf.Conf.Ecode)
http.Init(conf.Conf)
c := make(chan os.Signal, 1)
signal.Notify(c, syscall.SIGHUP, syscall.SIGQUIT, syscall.SIGTERM, syscall.SIGINT)
for {
s := <-c
log.Info("get a signal %s", s.String())
switch s {
case syscall.SIGQUIT, syscall.SIGTERM, syscall.SIGINT:
log.Info("[server] exit")
return
case syscall.SIGHUP:
default:
return
}
}
}

View File

@@ -0,0 +1,69 @@
IsTest = true
[log]
stdout = true
# dir = "/data/log/up/"
[Upcrm]
dsn = "upcrm:DdL6c5JaWCYKMAQ10PURbfeImow9HXlx@tcp(172.16.33.205:3306)/bilibili_upcrm?timeout=5s&readTimeout=5s&writeTimeout=5s&parseTime=true&loc=Local&charset=utf8,utf8mb4"
active = 5
idle = 1
idleTimeout = "4h"
[ArchiveOrm]
dsn = "test:test@tcp(172.16.33.205:3308)/bilibili_archive?timeout=5s&readTimeout=5s&writeTimeout=5s&parseTime=true&loc=Local&charset=utf8,utf8mb4"
active = 5
idle = 1
idleTimeout = "4h"
[job]
UpCheckDateDueTaskTime = "0 0 7 * * ?"
TaskScheduleTime = "0 0 1 * * ?"
CheckStateJobTime = "0 30 /1 * * ?"
UpdateUpTidJobTime = "0 15 0 * * ?"
[MailConf]
host = "smtp.exmail.qq.com"
port = 465
username = "manager@bilibili.com"
password = "123"
DueMailReceivers = [""] # 需要发送的额外管理员名称
[DatabusConf]
[DatabusConf.ArchiveNotify]
key = "4c76cbb7a985ac90"
secret= "43bb22ce34a6b13e7814f09cb8116522"
group= "ArchiveNotify-MainArchive-UpArchives-S"
topic= "ArchiveNotify-T"
action = "sub"
name = "up-job"
proto = "tcp"
addr = "172.18.33.50:6205"
idle = 5
active = 20
dialTimeout = "1s"
readTimeout = "60s"
writeTimeout = "1s"
idleTimeout = "10s"
[DatabusConf.Archive]
key = "4c76cbb7a985ac90"
secret= "43bb22ce34a6b13e7814f09cb8116522"
group= "Archive-MainArchive-UpService-S"
topic= "Archive-T"
action = "sub"
name = "up-job"
proto = "tcp"
addr = "172.18.33.50:6205"
idle = 5
active = 20
dialTimeout = "1s"
readTimeout = "60s"
writeTimeout = "1s"
idleTimeout = "10s"
[grpcclient]
[grpcclient.up]
timeout = "5s"
[grpcclient.archive]
timeout = "2s"