2021-07-11 21:19:37 +00:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
2021-08-14 21:43:30 +00:00
|
|
|
"os"
|
2021-07-29 19:54:55 +00:00
|
|
|
"sync"
|
2021-08-01 15:48:24 +00:00
|
|
|
"time"
|
2021-07-29 18:51:15 +00:00
|
|
|
|
2021-08-12 19:26:54 +00:00
|
|
|
"github.com/MedzikUser/go-utils/common"
|
2021-08-14 21:43:30 +00:00
|
|
|
"github.com/MedzikUser/go-utils/updater"
|
2021-07-11 21:19:37 +00:00
|
|
|
"gitlab.com/gaming0skar123/go/pingbot/backend"
|
|
|
|
"gitlab.com/gaming0skar123/go/pingbot/config"
|
2021-07-29 18:51:15 +00:00
|
|
|
"gitlab.com/gaming0skar123/go/pingbot/database/mongo"
|
2021-07-11 21:19:37 +00:00
|
|
|
"gitlab.com/gaming0skar123/go/pingbot/website"
|
|
|
|
)
|
|
|
|
|
|
|
|
var log = common.Log
|
|
|
|
|
|
|
|
func main() {
|
|
|
|
log.Info("You're using verion: ", config.Version)
|
|
|
|
|
2021-07-29 19:54:55 +00:00
|
|
|
var wg sync.WaitGroup
|
|
|
|
|
2021-07-29 18:51:15 +00:00
|
|
|
mongo.Connect()
|
|
|
|
|
|
|
|
if config.Toml.HTTP.Enabled {
|
2021-07-29 19:54:55 +00:00
|
|
|
wg.Add(1)
|
2021-07-29 18:51:15 +00:00
|
|
|
go website.Server()
|
|
|
|
} else {
|
|
|
|
log.Warn("HTTP Server -> Disabled")
|
|
|
|
}
|
|
|
|
|
|
|
|
if config.Toml.Backend.Enabled {
|
2021-07-29 19:54:55 +00:00
|
|
|
wg.Add(1)
|
2021-07-29 18:51:15 +00:00
|
|
|
go backend.Ticker()
|
|
|
|
} else {
|
|
|
|
log.Warn("Backend -> Disabled")
|
|
|
|
}
|
|
|
|
|
|
|
|
if config.Toml.AutoUpdate.Enabled {
|
2021-07-29 19:54:55 +00:00
|
|
|
wg.Add(1)
|
2021-08-14 21:43:30 +00:00
|
|
|
|
|
|
|
client := updater.Client{
|
|
|
|
GitHub: config.GH_Repo,
|
2021-08-15 14:38:12 +00:00
|
|
|
GitHubToken: config.GH_Token,
|
2021-08-14 21:43:30 +00:00
|
|
|
CheckEvery: config.Toml.AutoUpdate.Check * time.Minute,
|
|
|
|
Version: config.Version,
|
|
|
|
Binary: "pingbot.out",
|
|
|
|
AfterUpdate: func() {
|
|
|
|
log.Info("Updated!")
|
|
|
|
|
|
|
|
os.Exit(1)
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
|
|
|
go client.AutoUpdater()
|
2021-07-29 18:51:15 +00:00
|
|
|
} else {
|
|
|
|
log.Warn("Auto Update -> Disabled")
|
|
|
|
}
|
2021-07-11 21:19:37 +00:00
|
|
|
|
2021-08-01 15:48:24 +00:00
|
|
|
config.StartTime = time.Now()
|
|
|
|
|
2021-07-29 19:54:55 +00:00
|
|
|
wg.Wait()
|
2021-07-11 21:19:37 +00:00
|
|
|
}
|