All checks were successful
release-tag / release-image (push) Successful in 2m8s
39 lines
723 B
Go
39 lines
723 B
Go
package main
|
|
|
|
import (
|
|
"context"
|
|
"log"
|
|
"os"
|
|
"os/signal"
|
|
"syscall"
|
|
"time"
|
|
)
|
|
|
|
func main() {
|
|
cfg := loadConfig()
|
|
store, err := NewStore(cfg.DatabasePath)
|
|
if err != nil {
|
|
log.Fatal(err)
|
|
}
|
|
defer store.Close()
|
|
bot, err := NewBot(cfg, store)
|
|
if err != nil {
|
|
log.Fatal(err)
|
|
}
|
|
if err := bot.Start(); err != nil {
|
|
log.Fatal(err)
|
|
}
|
|
bot.ApplySavedRichPresence()
|
|
dashboard := StartDashboard(cfg, store, bot)
|
|
log.Println("Bot läuft. Beenden mit Ctrl+C.")
|
|
stop := make(chan os.Signal, 1)
|
|
signal.Notify(stop, syscall.SIGINT, syscall.SIGTERM)
|
|
<-stop
|
|
bot.Stop()
|
|
if dashboard != nil {
|
|
ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
|
|
defer cancel()
|
|
_ = dashboard.Shutdown(ctx)
|
|
}
|
|
}
|