package main import "os" import "sync" import "github.com/rs/zerolog" import "github.com/rs/zerolog/log" import "golang.org/x/crypto/ssh/terminal" func main() { os.Exit(app()) } func app() int { log.Logger = log.With().Caller().Logger() if terminal.IsTerminal(int(os.Stdout.Fd())) { log.Logger = log.Output(zerolog.ConsoleWriter{Out: os.Stderr}) } identify() zerolog.SetGlobalLevel(zerolog.InfoLevel) if os.Getenv("DEBUG") != "" { zerolog.SetGlobalLevel(zerolog.DebugLevel) } archiver := NewTootArchiver() api := new(TootArchiverAPIServer) api.archiver = archiver var wg sync.WaitGroup // start api webserver goroutine wg.Add(1) go func() { api.Serve() wg.Done() }() wg.Add(1) go func() { archiver.RunForever() wg.Done() }() wg.Wait() return 0 }