feat: add backend

This commit is contained in:
Ludvig Lundgren 2021-08-11 15:26:17 +02:00
parent bc418ff248
commit a838d994a6
68 changed files with 9561 additions and 0 deletions

43
internal/server/server.go Normal file
View file

@ -0,0 +1,43 @@
package server
import (
"sync"
"github.com/rs/zerolog/log"
"github.com/autobrr/autobrr/internal/indexer"
"github.com/autobrr/autobrr/internal/irc"
)
type Server struct {
Hostname string
Port int
indexerService indexer.Service
ircService irc.Service
stopWG sync.WaitGroup
lock sync.Mutex
}
func NewServer(ircSvc irc.Service, indexerSvc indexer.Service) *Server {
return &Server{
indexerService: indexerSvc,
ircService: ircSvc,
}
}
func (s *Server) Start() error {
log.Info().Msgf("Starting server. Listening on %v:%v", s.Hostname, s.Port)
// instantiate indexers
err := s.indexerService.Start()
if err != nil {
return err
}
// instantiate and start irc networks
s.ircService.StartHandlers()
return nil
}