main.go 1020 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. package main
  2. import (
  3. "fmt"
  4. "net/http"
  5. "os"
  6. "time"
  7. "github.com/IceWreck/BookStack2Site/downloader"
  8. "github.com/IceWreck/BookStack2Site/config"
  9. "github.com/rs/zerolog"
  10. )
  11. func main() {
  12. app := &config.Application{
  13. Logger: zerolog.New(
  14. zerolog.ConsoleWriter{
  15. Out: os.Stdout,
  16. TimeFormat: time.RFC822,
  17. },
  18. ).With().Timestamp().Logger(),
  19. }
  20. app.Config = config.LoadConfig(app)
  21. app.Logger.Info().Str("config", fmt.Sprint(app.Config)).Msg("")
  22. if app.Config.VerboseLogs {
  23. zerolog.SetGlobalLevel(zerolog.DebugLevel)
  24. } else {
  25. zerolog.SetGlobalLevel(zerolog.InfoLevel)
  26. }
  27. if app.Config.BookStackEndpoint == "" || app.Config.BookStackAPITokenID == "" || app.Config.BookStackAPITokenSecret == "" {
  28. app.Logger.Fatal().Msg("BookStackEndpoint, BookStackAPITokenID, BookStackAPITokenSecret cannot be empty")
  29. }
  30. app.Client = &http.Client{
  31. Timeout: 120 * time.Second,
  32. }
  33. app.Logger.Info().Msg("Trying to establish wiki structure. This might take a while.")
  34. downloader.Download(app)
  35. }