Feature: Tail live logs (#27)

* chore: add new yarn.lock

* chore: add pkgs

* feat: push events via server-sent-events

* feat(web): tail live logs

* fix: update irc network

* fix: set baseurl

* fix: headers
This commit is contained in:
Ludvig Lundgren 2021-09-07 22:23:27 +02:00 committed by GitHub
parent 11fcf1ead9
commit 09eb0b1716
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
14 changed files with 213 additions and 26 deletions

View file

@ -7,6 +7,7 @@ import (
"os/signal"
"syscall"
"github.com/r3labs/sse/v2"
"github.com/rs/zerolog/log"
"github.com/spf13/pflag"
_ "modernc.org/sqlite"
@ -40,8 +41,14 @@ func main() {
// read config
cfg = config.Read(configPath)
// setup server-sent-events
serverEvents := sse.New()
serverEvents.AutoReplay = false
serverEvents.CreateStream("logs")
// setup logger
logger.Setup(cfg)
logger.Setup(cfg, serverEvents)
// if configPath is set then put database inside that path, otherwise create wherever it's run
var dataSource = database.DataSourceName(configPath, "autobrr.db")
@ -85,7 +92,7 @@ func main() {
errorChannel := make(chan error)
go func() {
httpServer := http.NewServer(addr, cfg.BaseURL, actionService, authService, downloadClientService, filterService, indexerService, ircService)
httpServer := http.NewServer(serverEvents, addr, cfg.BaseURL, actionService, authService, downloadClientService, filterService, indexerService, ircService)
errorChannel <- httpServer.Open()
}()