application.go 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. package cmd
  2. import (
  3. "github.com/owncast/owncast/services/config"
  4. "github.com/owncast/owncast/services/metrics"
  5. "github.com/owncast/owncast/storage/configrepository"
  6. log "github.com/sirupsen/logrus"
  7. )
  8. type Application struct {
  9. configservice *config.Config
  10. metricsservice *metrics.Metrics
  11. configRepository *configrepository.SqlConfigRepository
  12. maximumConcurrentConnectionLimit int64
  13. }
  14. /*
  15. The order of this setup matters.
  16. - Parse flags
  17. - Set the session runtime values
  18. - Use the session values to configure data persistence
  19. */
  20. func (app *Application) Start() {
  21. app.configservice = config.Get()
  22. app.parseFlags()
  23. app.configureLogging(*enableDebugOptions, *enableVerboseLogging, app.configservice.LogDirectory)
  24. app.showStartupMessage()
  25. app.setSessionConfig()
  26. app.createDirectories()
  27. app.maximumConcurrentConnectionLimit = getMaximumConcurrentConnectionLimit()
  28. setSystemConcurrentConnectionLimit(app.maximumConcurrentConnectionLimit)
  29. // If we're restoring a backup, do that and exit.
  30. if *restoreDatabaseFile != "" {
  31. app.handleRestoreBackup(restoreDatabaseFile)
  32. log.Exit(0)
  33. }
  34. if *backupDirectory != "" {
  35. app.configservice.BackupDirectory = *backupDirectory
  36. }
  37. app.startServices()
  38. }