-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
60 lines (50 loc) · 1.27 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
58
59
60
package main
import (
"fmt"
"github.com/nexryai/watchmaker"
"lab.sda1.net/nexryai/hoyofeed/cache"
"lab.sda1.net/nexryai/hoyofeed/feed"
"lab.sda1.net/nexryai/hoyofeed/logger"
"lab.sda1.net/nexryai/hoyofeed/server"
"os"
"time"
)
func main() {
log := logger.GetLogger("Main")
log.ProgressInfo("Init memory...")
memory := cache.MultiTypeFeedCache{
StarRailXml: new(cache.MultiLangFeedCache),
StarRailJson: new(cache.MultiLangFeedCache),
GenshinXml: new(cache.MultiLangFeedCache),
GenshinJson: new(cache.MultiLangFeedCache),
}
log.ProgressOk()
// 20分おきにフィードを更新
log.ProgressInfo("Starting feed generate goroutine...")
// miHoYoの現地時刻を基準にする
tz, err := time.LoadLocation("Asia/Shanghai")
if err != nil {
log.FatalWithDetail("Failed to load timezone info", err)
}
timer := watchmaker.Timer{
BaseInterval: time.Minute * 20,
RunOnTheHour: true,
Delay: time.Second * 15,
Timezone: tz,
}
go func() {
for {
err := feed.GenerateFeed(&memory, os.Getenv("FEED_LANG"))
if err != nil {
fmt.Println("err:", err)
}
log.Info("feed updated")
// 待機
timer.WaitForNextScheduledTime()
}
}()
log.ProgressOk()
fmt.Println("\n")
log.Info("starting server...")
server.StartServer(&memory)
}