Commit 458d90c1 by 孙龙

定时任务

parent ec930826
......@@ -2,4 +2,5 @@
/.idea
/.DS_Store
/logs/*
/log/*
/config/*.toml
package main
import (
"flag"
"github.com/ichunt2019/logger"
"go-queue-server/dal/db"
"go-queue-server/util"
"time"
)
func initDb(dns string) (err error) {
err = db.Init(dns)
if err != nil {
return
}
return
}
var ConfigDir string
var LogDir string
// 解析命令行参数
func initArgs() {
// worker -config ./worker.json
// worker -h
flag.StringVar(&ConfigDir, "configDir", "", "配置文件")
flag.StringVar(&LogDir, "logDir", "", "日志目录")
flag.Parse()
}
func main() {
initArgs()
//初始化配置文件
util.Init(ConfigDir)
//
logConfig := make(map[string]string)
logConfig["log_path"] = LogDir+"order/orderSendPurchaseEmail"
logConfig["log_chan_size"] = "1000"
logger.InitLogger("file",logConfig)
logger.Init()
//初始化db
initDb(util.Configs.Liexin_databases.Dns)
t1 := time.NewTimer(time.Second * 5)
t2 := time.NewTimer(time.Second * 8)
for {
select {
case <-t1.C:
println("5s timer")
t1.Reset(time.Second * 5)
case <-t2.C:
println("8s timer")
t2.Reset(time.Second * 8)
}
}
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment