-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathcron.go
94 lines (80 loc) · 1.79 KB
/
cron.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
package main
import (
"log"
"github.com/FurqanSoftware/bullet/core"
"github.com/FurqanSoftware/bullet/spec"
"github.com/spf13/cobra"
)
var CronEnableCmd = &cobra.Command{
Use: "cron:enable",
Short: "Enable a cron job",
Long: `This command enables a cron job on the server.`,
Run: func(cmd *cobra.Command, args []string) {
spec, err := spec.ParseFile("Bulletspec")
if err != nil {
log.Fatal(err)
return
}
nodes, err := core.ParseNodeSet(Hosts, Port, Identity)
if err != nil {
log.Fatal(err)
return
}
nodes = core.SelectNodes(nodes)
err = core.CronEnable(nodes, spec, args)
if err != nil {
log.Fatal(err)
return
}
},
}
var CronDisableCmd = &cobra.Command{
Use: "cron:disable",
Short: "Disable a cron job",
Long: `This command disables a cron job on the server.`,
Run: func(cmd *cobra.Command, args []string) {
spec, err := spec.ParseFile("Bulletspec")
if err != nil {
log.Fatal(err)
return
}
nodes, err := core.ParseNodeSet(Hosts, Port, Identity)
if err != nil {
log.Fatal(err)
return
}
nodes = core.SelectNodes(nodes)
err = core.CronDisable(nodes, spec, args)
if err != nil {
log.Fatal(err)
return
}
},
}
var CronStatusCmd = &cobra.Command{
Use: "cron:status",
Short: "Print cron job status",
Long: `This command prints the status of all cron jobs.`,
Run: func(cmd *cobra.Command, args []string) {
spec, err := spec.ParseFile("Bulletspec")
if err != nil {
log.Fatal(err)
return
}
nodes, err := core.ParseNodeSet(Hosts, Port, Identity)
if err != nil {
log.Fatal(err)
return
}
err = core.CronStatus(nodes, spec, args)
if err != nil {
log.Fatal(err)
return
}
},
}
func init() {
RootCmd.AddCommand(CronEnableCmd)
RootCmd.AddCommand(CronDisableCmd)
RootCmd.AddCommand(CronStatusCmd)
}