Create & Init Project...
This commit is contained in:
42
app/job/bbq/recall/cmd/BUILD
Normal file
42
app/job/bbq/recall/cmd/BUILD
Normal file
@ -0,0 +1,42 @@
|
||||
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 = ["test.toml"],
|
||||
importpath = "go-common/app/job/bbq/recall/cmd",
|
||||
tags = ["automanaged"],
|
||||
visibility = ["//visibility:public"],
|
||||
deps = [
|
||||
"//app/job/bbq/recall/internal/conf:go_default_library",
|
||||
"//app/job/bbq/recall/internal/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"],
|
||||
)
|
61
app/job/bbq/recall/cmd/main.go
Normal file
61
app/job/bbq/recall/cmd/main.go
Normal file
@ -0,0 +1,61 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"flag"
|
||||
"os"
|
||||
"os/signal"
|
||||
"syscall"
|
||||
"time"
|
||||
|
||||
"go-common/app/job/bbq/recall/internal/conf"
|
||||
"go-common/app/job/bbq/recall/internal/service"
|
||||
"go-common/library/log"
|
||||
"go-common/library/net/trace"
|
||||
)
|
||||
|
||||
var (
|
||||
_serviceName string
|
||||
)
|
||||
|
||||
func init() {
|
||||
flag.StringVar(&_serviceName, "service", "", "run service name")
|
||||
}
|
||||
|
||||
func main() {
|
||||
flag.Parse()
|
||||
if err := conf.Init(); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
log.Init(conf.Conf.Log)
|
||||
defer log.Close()
|
||||
log.Info("recall-job start")
|
||||
trace.Init(conf.Conf.Tracer)
|
||||
defer trace.Close()
|
||||
svc := service.New(conf.Conf)
|
||||
defer svc.Close()
|
||||
|
||||
if _serviceName != "" {
|
||||
svc.RunSrv(_serviceName)
|
||||
} else {
|
||||
svc.InitCron()
|
||||
deamon()
|
||||
}
|
||||
}
|
||||
|
||||
func deamon() {
|
||||
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("recall-job exit")
|
||||
time.Sleep(time.Second)
|
||||
return
|
||||
case syscall.SIGHUP:
|
||||
default:
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
83
app/job/bbq/recall/cmd/test.toml
Normal file
83
app/job/bbq/recall/cmd/test.toml
Normal file
@ -0,0 +1,83 @@
|
||||
[log]
|
||||
stdout = true
|
||||
|
||||
[mysql]
|
||||
addr = "172.16.38.91:3306"
|
||||
dsn = "root:123456@tcp(172.16.38.91:3306)/bbq?allowNativePasswords=true&timeout=800ms&readTimeout=1200ms&writeTimeout=800ms&parseTime=true&loc=Local&charset=utf8,utf8mb4"
|
||||
readDSN = ["root:123456@tcp(172.16.38.91:3306)/bbq?allowNativePasswords=true&timeout=800ms&readTimeout=1200ms&writeTimeout=800ms&parseTime=true&loc=Local&charset=utf8,utf8mb4"]
|
||||
active = 20
|
||||
idle = 10
|
||||
idleTimeout ="4h"
|
||||
queryTimeout = "800ms"
|
||||
execTimeout = "800ms"
|
||||
tranTimeout = "1000ms"
|
||||
|
||||
[offlineMysql]
|
||||
addr = "172.16.38.91:3306"
|
||||
dsn = "root:123456@tcp(172.16.38.91:3306)/bbq?allowNativePasswords=true&timeout=800ms&readTimeout=1200ms&writeTimeout=800ms&parseTime=true&loc=Local&charset=utf8,utf8mb4"
|
||||
readDSN = ["root:123456@tcp(172.16.38.91:3306)/bbq?allowNativePasswords=true&timeout=800ms&readTimeout=1200ms&writeTimeout=800ms&parseTime=true&loc=Local&charset=utf8,utf8mb4"]
|
||||
active = 20
|
||||
idle = 10
|
||||
idleTimeout ="4h"
|
||||
queryTimeout = "800ms"
|
||||
execTimeout = "800ms"
|
||||
tranTimeout = "1000ms"
|
||||
|
||||
[cmsMysql]
|
||||
addr = "172.16.38.91:3306"
|
||||
dsn = "root:123456@tcp(172.16.38.91:3306)/bbq_cms?allowNativePasswords=true&timeout=800ms&readTimeout=1200ms&writeTimeout=800ms&parseTime=true&loc=Local&charset=utf8,utf8mb4"
|
||||
readDSN = ["root:123456@tcp(172.16.38.91:3306)/bbq_cms?allowNativePasswords=true&timeout=800ms&readTimeout=1200ms&writeTimeout=800ms&parseTime=true&loc=Local&charset=utf8,utf8mb4"]
|
||||
active = 20
|
||||
idle = 10
|
||||
idleTimeout ="4h"
|
||||
queryTimeout = "800ms"
|
||||
execTimeout = "800ms"
|
||||
tranTimeout = "1000ms"
|
||||
|
||||
[redis]
|
||||
name = "bbq-web"
|
||||
proto = "tcp"
|
||||
addr = "172.16.38.91:6379"
|
||||
idle = 10
|
||||
active = 10
|
||||
dialTimeout = "1s"
|
||||
readTimeout = "1s"
|
||||
writeTimeout = "1s"
|
||||
idleTimeout = "10s"
|
||||
expire = "1m"
|
||||
|
||||
[bfredis]
|
||||
name = "bbq-bf"
|
||||
proto = "tcp"
|
||||
addr = "172.16.38.91:6379"
|
||||
idle = 10
|
||||
active = 10
|
||||
dialTimeout = "1s"
|
||||
readTimeout = "1s"
|
||||
writeTimeout = "1s"
|
||||
idleTimeout = "10s"
|
||||
expire = "1m"
|
||||
|
||||
[berserker]
|
||||
[[berserker.keys]]
|
||||
owner = "daiwei"
|
||||
appkey = "66ed588a742c72408bc2d876afa8f7ca"
|
||||
secret = "7d7a63e37fe6af52a58fb4755b62360e"
|
||||
[[berserker.api]]
|
||||
name = "video_quality"
|
||||
url = "http://berserker.bilibili.co/avenger/api/175/query"
|
||||
[[berserker.api]]
|
||||
name = "video_view"
|
||||
url = "http://berserker.bilibili.co/avenger/api/154/query"
|
||||
|
||||
[job]
|
||||
[job.forwardIndex]
|
||||
jobName = "genForwardIndex"
|
||||
schedule = "@every 30m"
|
||||
input = "/Users/daiwei/Desktop/"
|
||||
output = "/Users/daiwei/forward_index.txt"
|
||||
[job.bloomfilter]
|
||||
jobName = "genBloomFilter"
|
||||
schedule = "@every 30m"
|
||||
input = ""
|
||||
output = ""
|
Reference in New Issue
Block a user