esbot/main.go

42 lines
904 B
Go

package main
import (
"os"
"git.netflux.io/rob/esbot/internal/http"
"git.netflux.io/rob/esbot/internal/lang"
"github.com/rs/zerolog"
"github.com/rs/zerolog/log"
)
func main() {
logger := log.Output(zerolog.ConsoleWriter{Out: os.Stdout})
accessToken := os.Getenv("ACCESS_TOKEN")
if accessToken == "" {
logger.Fatal().Msg("missing ACCESS_TOKEN")
}
listenAddr := os.Getenv("LISTEN_ADDR")
if listenAddr == "" {
logger.Fatal().Msg("missing LISTEN_ADDR")
}
baseURL := os.Getenv("BASE_URL")
if baseURL == "" {
logger.Fatal().Msg("missing BASE_URL")
}
insecureTLS := os.Getenv("INSECURE_TLS") == "yes"
if n, err := lang.Load(); err == nil {
logger.Info().Msgf("Loaded %d verbs", n)
} else {
logger.Fatal().Msgf("could not initialize languages: %v", err)
}
if err := http.ListenAndServe(listenAddr, baseURL, accessToken, insecureTLS, logger); err != nil {
panic(err)
}
}