-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
63 lines (49 loc) · 1.16 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
61
62
63
package main
import (
"os"
"os/signal"
"github.com/joho/godotenv"
"github.com/quackdiscord/bot/events"
"github.com/quackdiscord/bot/log"
"github.com/quackdiscord/bot/services"
)
func init() {
// load .env file
if err := godotenv.Load(".env"); err != nil {
// log.Fatal("No .env.local file found")
return
}
// set the environment
env := os.Getenv("ENVIORNMENT")
// log.SetOutput(os.Stdout)
// log.SetLevel(log.InfoLevel)
// log.SetFormatter(&log.TextFormatter{
// ForceColors: true,
// FullTimestamp: true,
// })
if env == "dev" {
log.Warn().Msg("Running in development mode")
}
}
func main() {
services.ReadyMessageCache()
services.ReadyEventQueue(1000)
// connect services
services.ConnectRedis()
services.ConnectDB()
events.RegisterEvents()
services.ConnectDiscord(events.Events)
// start the event queue
go services.EQ.Start(3)
stop := make(chan os.Signal, 1)
signal.Notify(stop, os.Interrupt)
log.Info().Msg("Press Ctrl+C to exit")
// handle shutdown
<-stop
log.Warn().Msg("Shutting down")
services.DisconnectDiscord()
services.DisconnectDB()
services.DisconnectRedis()
services.EQ.Stop()
log.Info().Msg("Goodbye!")
}