123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354 |
- package main
- import (
- "customer_project/config"
- "fmt"
- "github.com/robfig/cron/v3"
- util "jygit.jydev.jianyu360.cn/data_processing/common_utils"
- "jygit.jydev.jianyu360.cn/data_processing/common_utils/log"
- "net"
- "net/http"
- "net/rpc"
- "os"
- )
- var (
- updatePool chan []map[string]interface{}
- updateSp chan bool
- saveSize int
- )
- func init() {
- config.Init("./common.toml")
- InitLog()
- InitMysql()
- }
- func main() {
- loadData()
- go RpcService()
- taskProject()
- crn := cron.New()
- _, _ = crn.AddFunc("*/10 * * * *", func() {
- log.Info("start...")
- taskProject()
- })
- crn.Start()
- ch := make(chan bool, 1)
- <-ch
- }
- func RpcService() {
- rpc.Register(new(JyService)) // 注册rpc服务
- rpc.HandleHTTP() // 采用http协议作为rpc载体
- util.Debug(config.Conf.Serve.RpcServer)
- lis, err := net.Listen("tcp", config.Conf.Serve.RpcServer)
- if err != nil {
- util.Debug("fatal error: ", err)
- }
- _, _ = fmt.Fprintf(os.Stdout, "%s\n", "start connection")
- _ = http.Serve(lis, nil)
- }
|