2017-03-04 12:35:53 +01:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
2021-03-19 21:55:12 +01:00
|
|
|
"embed"
|
2018-11-29 22:20:57 +01:00
|
|
|
"flag"
|
2017-09-11 19:51:29 +02:00
|
|
|
|
2018-12-01 17:46:24 +01:00
|
|
|
"github.com/gempir/justlog/api"
|
2018-12-06 22:58:42 +01:00
|
|
|
"github.com/gempir/justlog/archiver"
|
2018-12-07 21:31:15 +01:00
|
|
|
"github.com/gempir/justlog/bot"
|
2020-03-08 15:22:03 +01:00
|
|
|
"github.com/gempir/justlog/config"
|
2018-12-01 17:46:24 +01:00
|
|
|
"github.com/gempir/justlog/filelog"
|
2018-12-02 19:23:54 +01:00
|
|
|
"github.com/gempir/justlog/helix"
|
2017-03-04 12:35:53 +01:00
|
|
|
)
|
|
|
|
|
2021-03-19 21:55:12 +01:00
|
|
|
// content holds our static web server content.
|
2023-02-28 21:29:09 +02:00
|
|
|
//
|
|
|
|
//go:embed web/dist/*
|
2021-03-19 21:55:12 +01:00
|
|
|
var assets embed.FS
|
|
|
|
|
2017-03-04 12:35:53 +01:00
|
|
|
func main() {
|
2018-11-29 22:20:57 +01:00
|
|
|
|
|
|
|
configFile := flag.String("config", "config.json", "json config file")
|
|
|
|
flag.Parse()
|
2017-03-04 12:35:53 +01:00
|
|
|
|
2020-03-08 15:22:03 +01:00
|
|
|
cfg := config.NewConfig(*configFile)
|
|
|
|
|
2018-11-29 22:20:57 +01:00
|
|
|
fileLogger := filelog.NewFileLogger(cfg.LogsDirectory)
|
2020-05-05 22:04:11 +02:00
|
|
|
helixClient := helix.NewClient(cfg.ClientID, cfg.ClientSecret)
|
2020-05-05 22:45:58 +02:00
|
|
|
go helixClient.StartRefreshTokenRoutine()
|
2020-10-01 00:39:59 +02:00
|
|
|
|
|
|
|
if cfg.Archive {
|
|
|
|
archiver := archiver.NewArchiver(cfg.LogsDirectory)
|
|
|
|
go archiver.Boot()
|
|
|
|
}
|
2018-12-02 14:53:01 +01:00
|
|
|
|
2020-09-26 01:45:18 +02:00
|
|
|
bot := bot.NewBot(cfg, &helixClient, &fileLogger)
|
|
|
|
|
2021-04-16 18:03:41 +02:00
|
|
|
apiServer := api.NewServer(cfg, bot, &fileLogger, &helixClient, assets)
|
2018-12-02 14:53:01 +01:00
|
|
|
go apiServer.Init()
|
|
|
|
|
2020-03-08 17:54:06 +01:00
|
|
|
bot.Connect()
|
2017-03-04 12:35:53 +01:00
|
|
|
}
|