-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
47 lines (36 loc) · 807 Bytes
/
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
package main
import (
"fmt"
"runtime"
"time"
"github.com/Luna-devv/nekostic/aggregate"
"github.com/Luna-devv/nekostic/api"
"github.com/Luna-devv/nekostic/config"
"github.com/go-co-op/gocron"
_ "github.com/joho/godotenv/autoload"
"github.com/redis/go-redis/v9"
)
func task() {
conf := config.Get()
client := redis.NewClient(&redis.Options{
Addr: conf.Redis.Addr,
Password: conf.Redis.Password,
Username: conf.Redis.Username,
DB: conf.Redis.Db,
})
aggregate.Commands(client)
aggregate.Tags(client)
client.Close()
}
func main() {
conf := config.Get()
if runtime.GOOS == "windows" {
task()
return
}
fmt.Println("Starting cron job...")
scheduler := gocron.NewScheduler(time.UTC)
scheduler.Cron("0 23 * * *").Do(task)
scheduler.StartAsync()
api.New(conf)
}