-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
57 lines (49 loc) · 1.01 KB
/
main.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
package main
import (
"os"
"log"
"github.com/stakelink/substrate-crond/cron"
"github.com/urfave/cli/v2"
)
func Run(ctx *cli.Context) error {
c, err := cron.New(ctx.String("rpc-url"))
if err != nil {
return err
}
err = c.LoadCrontab(ctx.String("crontab-file"))
if err != nil {
return err
}
return c.Run()
}
func main() {
app := &cli.App{
Name: "substrate-crond",
Usage: "Daemon to execute scheduled jobs based on Substrate activity",
Action: Run,
Flags: []cli.Flag {
&cli.StringFlag{
Name: "rpc-url",
Aliases: []string{"r"},
Value: "wss://rpc.polkadot.io",
Usage: "",
},
&cli.StringFlag{
Name: "crontab-file",
Aliases: []string{"c"},
Value: "/etc/substrate-crond/crontab",
Usage: "",
},
&cli.BoolFlag{
Name: "daemon",
Aliases: []string{"d"},
Value: false,
Usage: "",
},
},
}
err := app.Run(os.Args)
if err != nil {
log.Fatal(err)
}
}