2020-05-24 02:57:49 +02:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
2020-06-25 10:19:08 +02:00
|
|
|
"flag"
|
2020-06-24 21:55:49 +02:00
|
|
|
"fmt"
|
|
|
|
|
2020-11-07 00:12:35 +01:00
|
|
|
"github.com/markbates/pkger"
|
2020-10-30 02:17:04 +01:00
|
|
|
"github.com/owncast/owncast/logging"
|
2020-06-25 10:25:28 +02:00
|
|
|
"github.com/sirupsen/logrus"
|
2020-05-24 02:57:49 +02:00
|
|
|
log "github.com/sirupsen/logrus"
|
2020-06-03 02:35:49 +02:00
|
|
|
|
2020-10-05 19:07:09 +02:00
|
|
|
"github.com/owncast/owncast/config"
|
|
|
|
"github.com/owncast/owncast/core"
|
2020-10-26 16:55:31 +01:00
|
|
|
"github.com/owncast/owncast/core/data"
|
2020-10-05 19:07:09 +02:00
|
|
|
"github.com/owncast/owncast/metrics"
|
|
|
|
"github.com/owncast/owncast/router"
|
2020-06-23 03:11:56 +02:00
|
|
|
)
|
2020-05-30 03:08:33 +02:00
|
|
|
|
2020-06-24 21:55:49 +02:00
|
|
|
// the following are injected at build-time
|
|
|
|
var (
|
|
|
|
//GitCommit is the commit which this version of owncast is running
|
|
|
|
GitCommit = "unknown"
|
|
|
|
//BuildVersion is the version
|
|
|
|
BuildVersion = "0.0.0"
|
|
|
|
//BuildType is the type of build
|
|
|
|
BuildType = "localdev"
|
|
|
|
)
|
|
|
|
|
2020-06-01 21:15:07 +02:00
|
|
|
func main() {
|
2020-07-07 06:27:31 +02:00
|
|
|
configureLogging()
|
|
|
|
|
2020-11-04 02:34:25 +01:00
|
|
|
log.Infoln(getReleaseString())
|
2020-11-07 00:12:35 +01:00
|
|
|
// Enable bundling of admin assets
|
|
|
|
pkger.Include("/admin")
|
2020-06-11 22:33:20 +02:00
|
|
|
|
2020-06-25 10:19:08 +02:00
|
|
|
configFile := flag.String("configFile", "config.yaml", "Config File full path. Defaults to current folder")
|
2020-10-26 16:55:31 +01:00
|
|
|
dbFile := flag.String("database", "", "Path to the database file.")
|
2020-06-25 10:25:28 +02:00
|
|
|
enableDebugOptions := flag.Bool("enableDebugFeatures", false, "Enable additional debugging options.")
|
2020-07-07 06:27:31 +02:00
|
|
|
enableVerboseLogging := flag.Bool("enableVerboseLogging", false, "Enable additional logging.")
|
2020-06-25 10:25:28 +02:00
|
|
|
|
2020-06-25 10:19:08 +02:00
|
|
|
flag.Parse()
|
2020-06-11 22:33:20 +02:00
|
|
|
|
2020-06-25 10:25:28 +02:00
|
|
|
if *enableDebugOptions {
|
|
|
|
logrus.SetReportCaller(true)
|
|
|
|
}
|
|
|
|
|
2020-07-07 06:27:31 +02:00
|
|
|
if *enableVerboseLogging {
|
|
|
|
log.SetLevel(log.TraceLevel)
|
|
|
|
} else {
|
|
|
|
log.SetLevel(log.InfoLevel)
|
|
|
|
}
|
|
|
|
|
2020-11-04 02:34:25 +01:00
|
|
|
if err := config.Load(*configFile, getReleaseString(), getVersionNumber()); err != nil {
|
2020-06-23 03:11:56 +02:00
|
|
|
panic(err)
|
2020-06-02 09:27:54 +02:00
|
|
|
}
|
2020-07-09 03:27:24 +02:00
|
|
|
config.Config.EnableDebugFeatures = *enableDebugOptions
|
2020-06-02 09:27:54 +02:00
|
|
|
|
2020-10-26 16:55:31 +01:00
|
|
|
if *dbFile != "" {
|
|
|
|
config.Config.DatabaseFilePath = *dbFile
|
|
|
|
} else if config.Config.DatabaseFilePath == "" {
|
|
|
|
config.Config.DatabaseFilePath = config.Config.GetDataFilePath()
|
2020-07-16 02:20:47 +02:00
|
|
|
}
|
|
|
|
|
2020-08-27 17:50:27 +02:00
|
|
|
go metrics.Start()
|
2020-08-27 09:37:32 +02:00
|
|
|
|
2020-10-26 16:55:31 +01:00
|
|
|
data.SetupPersistence()
|
|
|
|
|
2020-06-23 03:11:56 +02:00
|
|
|
// starts the core
|
|
|
|
if err := core.Start(); err != nil {
|
2020-07-07 06:27:31 +02:00
|
|
|
log.Error("failed to start the core package")
|
2020-06-23 03:11:56 +02:00
|
|
|
panic(err)
|
2020-06-10 10:16:17 +02:00
|
|
|
}
|
2020-06-02 09:27:54 +02:00
|
|
|
|
2020-06-23 03:11:56 +02:00
|
|
|
if err := router.Start(); err != nil {
|
2020-07-07 06:27:31 +02:00
|
|
|
log.Error("failed to start/run the router")
|
2020-06-23 03:11:56 +02:00
|
|
|
panic(err)
|
2020-06-16 01:27:58 +02:00
|
|
|
}
|
2020-06-02 09:27:54 +02:00
|
|
|
}
|
2020-06-24 21:55:49 +02:00
|
|
|
|
2020-11-04 02:34:25 +01:00
|
|
|
//getReleaseString gets the version string
|
|
|
|
func getReleaseString() string {
|
2020-06-24 21:55:49 +02:00
|
|
|
return fmt.Sprintf("Owncast v%s-%s (%s)", BuildVersion, BuildType, GitCommit)
|
|
|
|
}
|
2020-07-07 06:27:31 +02:00
|
|
|
|
2020-11-04 02:34:25 +01:00
|
|
|
func getVersionNumber() string {
|
|
|
|
return BuildVersion
|
|
|
|
}
|
|
|
|
|
2020-07-07 06:27:31 +02:00
|
|
|
func configureLogging() {
|
2020-10-30 02:17:04 +01:00
|
|
|
logging.Setup()
|
2020-07-07 06:27:31 +02:00
|
|
|
log.SetFormatter(&log.TextFormatter{
|
|
|
|
FullTimestamp: true,
|
|
|
|
})
|
|
|
|
}
|