justlog/main.go

43 lines
916 B
Go
Raw Normal View History

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