Create & Init Project...
This commit is contained in:
44
app/interface/bbq/wechat/cmd/BUILD
Normal file
44
app/interface/bbq/wechat/cmd/BUILD
Normal 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 = ["test.toml"],
|
||||
importpath = "go-common/app/interface/bbq/wechat/cmd",
|
||||
tags = ["automanaged"],
|
||||
visibility = ["//visibility:public"],
|
||||
deps = [
|
||||
"//app/interface/bbq/wechat/internal/conf:go_default_library",
|
||||
"//app/interface/bbq/wechat/internal/server/http:go_default_library",
|
||||
"//app/interface/bbq/wechat/internal/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"],
|
||||
)
|
48
app/interface/bbq/wechat/cmd/main.go
Normal file
48
app/interface/bbq/wechat/cmd/main.go
Normal file
@ -0,0 +1,48 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"flag"
|
||||
"os"
|
||||
"os/signal"
|
||||
"syscall"
|
||||
"time"
|
||||
|
||||
"go-common/app/interface/bbq/wechat/internal/conf"
|
||||
"go-common/app/interface/bbq/wechat/internal/server/http"
|
||||
"go-common/app/interface/bbq/wechat/internal/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 {
|
||||
panic(err)
|
||||
}
|
||||
log.Init(conf.Conf.Log)
|
||||
defer log.Close()
|
||||
log.Info("wechat-interface start")
|
||||
trace.Init(conf.Conf.Tracer)
|
||||
defer trace.Close()
|
||||
|
||||
ecode.Init(conf.Conf.Ecode)
|
||||
svc := service.New(conf.Conf)
|
||||
http.Init(conf.Conf, svc)
|
||||
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:
|
||||
svc.Close()
|
||||
log.Info("wechat-interface exit")
|
||||
time.Sleep(time.Second)
|
||||
return
|
||||
case syscall.SIGHUP:
|
||||
default:
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
28
app/interface/bbq/wechat/cmd/test.toml
Normal file
28
app/interface/bbq/wechat/cmd/test.toml
Normal file
@ -0,0 +1,28 @@
|
||||
[log]
|
||||
stdout = true
|
||||
# dir = "./log/bbq"
|
||||
v = 5
|
||||
|
||||
[bm]
|
||||
addr = "0.0.0.0:8808"
|
||||
timeout = "2s"
|
||||
|
||||
[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"
|
||||
|
||||
[weixin]
|
||||
appid = "wx0cdd857da509e66d"
|
||||
secret = "99c0b103f59ab79c7b705e3e93a1d4f3"
|
||||
|
||||
[urls]
|
||||
weixin = "https://api.weixin.qq.com/cgi-bin/token"
|
||||
jsapi = "https://api.weixin.qq.com/cgi-bin/ticket/getticket"
|
Reference in New Issue
Block a user