Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
孙龙
/
go-crontab
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
e9a3f50d
authored
Apr 30, 2020
by
孙龙
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
up
parent
eab8f8bf
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
19 additions
and
15 deletions
main.go
readme.md
main.go
View file @
e9a3f50d
...
...
@@ -35,14 +35,15 @@ func main(){
//kv.Delete(context.TODO(),"/cron/jobs/192.168.2.246/job1",clientv3.WithPrefix())
//kv.Delete(context.TODO(),"/cron/jobs",clientv3.WithPrefix())
//kv.Delete(context.TODO(),"/cron/oncejobs",clientv3.WithPrefix())
//
//return
//新增定时任务
//putResp, err := kv.Put(context.TODO(),"/cron/jobs/192.168.2.232/job2","{\"name\":\"job2\",\"command\":\"D:/phpstudy/PHPTutorial/php/php-5.6.27-nts/php E:/WWW/a.php\",\"cronExpr\":\"*/7 * * * * * *\"}",clientv3.WithPrevKV())
//putResp, err := kv.Put(context.TODO(),"/cron/jobs/192.168.2.246/job2","{\"name\":\"job2\",\"command\":\" echo hello world\",\"cronExpr\":\"*/5 * * * * * *\"}",clientv3.WithPrevKV())
putResp
,
err
:=
kv
.
Put
(
context
.
TODO
(),
"/cron/jobs/192.168.2.246/job3"
,
"{
\"
name
\"
:
\"
job3
\"
,
\"
command
\"
:
\"
echo hello boy
\"
,
\"
cronExpr
\"
:
\"
*/10 * * * * * *
\"
}"
,
clientv3
.
WithPrevKV
())
//
putResp, err := kv.Put(context.TODO(),"/cron/jobs/192.168.2.246/job3","{\"name\":\"job3\",\"command\":\" echo hello boy\",\"cronExpr\":\"*/10 * * * * * *\"}",clientv3.WithPrevKV())
//fmt.Println(putResp)
//fmt.Println(err)
...
...
@@ -53,17 +54,17 @@ func main(){
//强杀任务
//putResp, err := kv.Put(context.TODO(),"/cron/killer/192.168.2.246/job10","")
if
err
!=
nil
{
fmt
.
Println
(
err
)
}
else
{
fmt
.
Println
(
"Revision:"
,
putResp
.
Header
.
Revision
)
if
putResp
.
PrevKv
!=
nil
{
fmt
.
Println
(
"key:"
,
string
(
putResp
.
PrevKv
.
Key
))
fmt
.
Println
(
"Value:"
,
string
(
putResp
.
PrevKv
.
Value
))
fmt
.
Println
(
"Version:"
,
string
(
putResp
.
PrevKv
.
Version
))
}
}
//
//
if err != nil{
//
fmt.Println(err)
//
}else{
//
fmt.Println("Revision:",putResp.Header.Revision)
//
if putResp.PrevKv != nil{
//
fmt.Println("key:",string(putResp.PrevKv.Key))
//
fmt.Println("Value:",string(putResp.PrevKv.Value))
//
fmt.Println("Version:",string(putResp.PrevKv.Version))
//
}
//
}
//查询
getResp
,
err
=
kv
.
Get
(
context
.
TODO
(),
"/cron/jobs"
,
clientv3
.
WithPrefix
())
...
...
readme.md
View file @
e9a3f50d
go run .
\w
orker
\m
ain
\w
orker.go -config=./worker
\m
ain
\w
orker.json
\ No newline at end of file
go run .
\w
orker
\m
ain
\w
orker.go -config=./worker
\m
ain
\w
orker.json
go build -o {path}/cmd/worker {path}/worker/main/worker.go
\ No newline at end of file
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