feta/main.go

50 lines
791 B
Go
Raw Normal View History

2019-10-24 10:38:16 +00:00
package main
2019-11-02 06:56:17 +00:00
import "os"
import "sync"
import "github.com/rs/zerolog"
import "github.com/rs/zerolog/log"
import "golang.org/x/crypto/ssh/terminal"
2019-10-24 10:38:16 +00:00
func main() {
os.Exit(app())
}
func app() int {
2019-10-24 12:41:05 +00:00
log.Logger = log.With().Caller().Logger()
2019-10-24 10:38:16 +00:00
if terminal.IsTerminal(int(os.Stdout.Fd())) {
log.Logger = log.Output(zerolog.ConsoleWriter{Out: os.Stderr})
}
identify()
zerolog.SetGlobalLevel(zerolog.InfoLevel)
2019-11-02 06:56:17 +00:00
if os.Getenv("DEBUG") != "" {
2019-10-24 10:38:16 +00:00
zerolog.SetGlobalLevel(zerolog.DebugLevel)
}
2019-11-02 06:56:17 +00:00
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
2019-10-24 10:38:16 +00:00
}