-
Notifications
You must be signed in to change notification settings - Fork 911
/
main.go
54 lines (43 loc) · 1.25 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
package main
import (
"log"
"os"
"time"
"github.com/botlabs-gg/yagpdb/v2/lib/discordgo"
"github.com/botlabs-gg/yagpdb/v2/lib/dshardorchestrator"
"github.com/botlabs-gg/yagpdb/v2/lib/dshardorchestrator/orchestrator"
"github.com/botlabs-gg/yagpdb/v2/lib/dshardorchestrator/orchestrator/rest"
)
func main() {
discordSession, err := discordgo.New(os.Getenv("DG_TOKEN"))
if err != nil {
log.Fatal("failed initilazing discord session: ", err)
}
orch := orchestrator.NewStandardOrchestrator(discordSession)
orch.NodeLauncher = orchestrator.NewNodeLauncher("./dso-sample-bot", nil, nil)
orch.Logger = &dshardorchestrator.StdLogger{
Level: dshardorchestrator.LogDebug,
}
orch.ShardCountProvider = &mockShardCountProvider{
NumShards: 10,
}
orch.MaxShardsPerNode = 5
orch.MaxNodeDowntimeBeforeRestart = time.Second * 10
orch.EnsureAllShardsRunning = true
err = orch.Start("127.0.0.1:7447")
if err != nil {
log.Fatal("failed starting orchestrator: ", err)
}
api := rest.NewRESTAPI(orch, "127.0.0.1:7448")
err = api.Run()
if err != nil {
log.Fatal("failed starting rest api: ", err)
}
select {}
}
type mockShardCountProvider struct {
NumShards int
}
func (m *mockShardCountProvider) GetTotalShardCount() (int, error) {
return m.NumShards, nil
}