Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
lzzzzl
/
golang_seo_server
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
fa223cd0
authored
Dec 03, 2020
by
lzzzzl
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
修改定时
parent
aa1a834f
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
28 additions
and
28 deletions
cmd/main.go
cmd/main.go
View file @
fa223cd0
...
...
@@ -5,7 +5,6 @@ import (
"fmt"
"github.com/ichunt2019/golang-rbmq-sl/utils/rabbitmq"
"github.com/ichunt2019/logger"
"github.com/robfig/cron/v3"
"github.com/tidwall/gjson"
"golang-seo-server/collect/lxmain"
"golang-seo-server/collect/ly"
...
...
@@ -104,35 +103,36 @@ func main() {
fmt
.
Println
(
lyRemain
)
fmt
.
Println
(
mainRemain
)
fmt
.
Println
(
mipRemain
)
ly
.
RunLyTask
(
lyRemain
,
ConfigDir
)
lxmain
.
RunMainTask
(
mainRemain
,
ConfigDir
)
mip
.
RunMipTask
(
mipRemain
,
ConfigDir
)
// 根据cron表达式进行时间调度,cron可以精确到秒
//crontab := cron.New() 默认从分开始进行时间调度
crontab
:=
cron
.
New
(
cron
.
WithSeconds
())
//精确到秒
//定义定时器调用的任务函数
task
:=
func
()
{
logger
.
Info
(
"定时任务启动,每天凌晨1点运行"
)
ly
.
RunLyTask
(
lyRemain
,
ConfigDir
)
lxmain
.
RunMainTask
(
mainRemain
,
ConfigDir
)
mip
.
RunMipTask
(
mipRemain
,
ConfigDir
)
//
defer
db
.
SeoDB
.
Close
()
defer
db
.
SpuDB
.
Close
()
defer
db
.
GoodsDB
.
Close
()
defer
db
.
SkuDB
.
Close
()
defer
db
.
LxDB
.
Close
()
////fmt.Println("******** ******* *******")
//fmt.Println("Time now:", time.Now().Format("2006-01-02 15:04:05"))
}
//定时任务
spec
:=
"0 0 1 * * ?"
//cron表达式,每天凌晨1点运行
//spec := "2 * * * * *" //cron表达式,表示每分钟的第2s执行一次
// 添加定时任务,
_
,
_
=
crontab
.
AddFunc
(
spec
,
task
)
// 启动定时器
crontab
.
Start
()
//阻塞主线程停止
select
{}
//// 根据cron表达式进行时间调度,cron可以精确到秒
////crontab := cron.New() 默认从分开始进行时间调度
//crontab := cron.New(cron.WithSeconds()) //精确到秒
////定义定时器调用的任务函数
//task := func() {
// logger.Info("定时任务启动,每天凌晨1点运行")
// ly.RunLyTask(lyRemain, ConfigDir)
// lxmain.RunMainTask(mainRemain, ConfigDir)
// mip.RunMipTask(mipRemain, ConfigDir)
// //
// defer db.SeoDB.Close()
// defer db.SpuDB.Close()
// defer db.GoodsDB.Close()
// defer db.SkuDB.Close()
// defer db.LxDB.Close()
// ////fmt.Println("******** ******* *******")
// //fmt.Println("Time now:", time.Now().Format("2006-01-02 15:04:05"))
//}
////定时任务
//spec := "0 0 1 * * ?" //cron表达式,每天凌晨1点运行
////spec := "2 * * * * *" //cron表达式,表示每分钟的第2s执行一次
//// 添加定时任务,
//_, _ = crontab.AddFunc(spec, task)
//// 启动定时器
//crontab.Start()
////阻塞主线程停止
//select {}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment