Initial commit

This commit is contained in:
Donny
2019-04-22 20:46:32 +08:00
commit 49ab8aadd1
25441 changed files with 4055000 additions and 0 deletions

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 = ["search-service-test.toml"],
importpath = "go-common/app/service/main/search/cmd",
tags = ["automanaged"],
visibility = ["//visibility:public"],
deps = [
"//app/service/main/search/conf:go_default_library",
"//app/service/main/search/http:go_default_library",
"//app/service/main/search/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"],
)

View File

@@ -0,0 +1,48 @@
package main
import (
"flag"
"os"
"os/signal"
"syscall"
"time"
"go-common/app/service/main/search/conf"
"go-common/app/service/main/search/http"
"go-common/app/service/main/search/service"
"go-common/library/log"
"go-common/library/net/trace"
)
func main() {
flag.Parse()
// init conf,log,trace,stat,perf.
if err := conf.Init(); err != nil {
panic(err)
}
log.Init(conf.Conf.Xlog)
defer log.Close()
trace.Init(conf.Conf.Tracer)
defer trace.Close()
// service init
svr := service.New(conf.Conf)
http.Init(conf.Conf, svr)
// signal handler
log.Info("search-interface start")
c := make(chan os.Signal, 1)
signal.Notify(c, syscall.SIGHUP, syscall.SIGQUIT, syscall.SIGTERM, syscall.SIGINT)
for {
s := <-c
log.Info("search-interface get a signal %s", s.String())
switch s {
case syscall.SIGQUIT, syscall.SIGTERM, syscall.SIGSTOP, syscall.SIGINT:
time.Sleep(time.Second * 2)
log.Info("search-interface exit")
return
case syscall.SIGHUP:
// TODO reload
default:
return
}
}
}

View File

@@ -0,0 +1,68 @@
version = "0.0.1"
user = "nobody"
pid = "/tmp/search-service.pid"
dir = "./"
perf = "127.0.0.1:7320"
trace = false
debug = false
[xlog]
dir = "/data/log/search-service/"
[HTTPServer]
addr = "0.0.0.0:7322"
maxListen = 1000
timeout = "1s"
readTimeout = "1s"
writeTimeout = "1s"
[pagination]
pageNum = 1
pageSize = 30
maxPageNum = 5000
maxPageSize = 1000
[es]
[es.archiveInternal]
addr = ["http://172.18.33.71:9200"]
[es.dmInternal]
addr = ["http://172.18.33.71:9200"]
[es.dmExternal]
addr = ["http://172.18.33.71:9200"]
[es.replyInternal]
addr = ["http://172.18.33.71:9200"]
[es.replyExternal]
addr = ["http://172.18.33.71:9200"]
[es.articleInternal]
addr = ["http://172.18.33.71:9200"]
[redis]
name = "search-api"
proto = "tcp"
addr = "172.18.33.71:6379"
active = 10
idle = 5
dialTimeout = "1s"
readTimeout = "1s"
writeTimeout = "1s"
idleTimeout = "10s"
expire = "24h"
[SMS]
phone = "17621966518"
token = "f5a658b2-5926-4b71-96c3-7d3777b7d256"
[httpClient]
key = "app key"
secret = "app secret"
dial = "100ms"
timeout = "1s"
keepAlive = "60s"
timer = 128
[httpClient.breaker]
window ="10s"
sleep ="10ms"
bucket = 10
ratio = 0.5
request = 100