2020-05-24 03:57:49 +03:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
2020-06-25 11:19:08 +03:00
|
|
|
"flag"
|
2020-06-24 22:55:49 +03:00
|
|
|
"fmt"
|
|
|
|
|
2020-06-25 11:25:28 +03:00
|
|
|
"github.com/sirupsen/logrus"
|
2020-05-24 03:57:49 +03:00
|
|
|
log "github.com/sirupsen/logrus"
|
2020-06-03 03:35:49 +03:00
|
|
|
|
2020-06-23 04:11:56 +03:00
|
|
|
"github.com/gabek/owncast/config"
|
|
|
|
"github.com/gabek/owncast/core"
|
2020-08-27 10:37:32 +03:00
|
|
|
"github.com/gabek/owncast/metrics"
|
2020-06-23 04:11:56 +03:00
|
|
|
"github.com/gabek/owncast/router"
|
|
|
|
)
|
2020-05-30 04:08:33 +03:00
|
|
|
|
2020-06-24 22:55:49 +03: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 22:15:07 +03:00
|
|
|
func main() {
|
2020-07-07 07:27:31 +03:00
|
|
|
configureLogging()
|
|
|
|
|
|
|
|
log.Infoln(getVersion())
|
2020-06-11 23:33:20 +03:00
|
|
|
|
2020-06-25 11:19:08 +03:00
|
|
|
configFile := flag.String("configFile", "config.yaml", "Config File full path. Defaults to current folder")
|
2020-07-16 03:20:47 +03:00
|
|
|
chatDbFile := flag.String("chatDatabase", "", "Path to the chat database file.")
|
2020-06-25 11:25:28 +03:00
|
|
|
enableDebugOptions := flag.Bool("enableDebugFeatures", false, "Enable additional debugging options.")
|
2020-07-07 07:27:31 +03:00
|
|
|
enableVerboseLogging := flag.Bool("enableVerboseLogging", false, "Enable additional logging.")
|
2020-06-25 11:25:28 +03:00
|
|
|
|
2020-06-25 11:19:08 +03:00
|
|
|
flag.Parse()
|
2020-06-11 23:33:20 +03:00
|
|
|
|
2020-06-25 11:25:28 +03:00
|
|
|
if *enableDebugOptions {
|
|
|
|
logrus.SetReportCaller(true)
|
|
|
|
}
|
|
|
|
|
2020-07-07 07:27:31 +03:00
|
|
|
if *enableVerboseLogging {
|
|
|
|
log.SetLevel(log.TraceLevel)
|
|
|
|
} else {
|
|
|
|
log.SetLevel(log.InfoLevel)
|
|
|
|
}
|
|
|
|
|
2020-07-01 03:48:26 +03:00
|
|
|
if err := config.Load(*configFile, getVersion()); err != nil {
|
2020-06-23 04:11:56 +03:00
|
|
|
panic(err)
|
2020-06-02 10:27:54 +03:00
|
|
|
}
|
2020-07-09 04:27:24 +03:00
|
|
|
config.Config.EnableDebugFeatures = *enableDebugOptions
|
2020-06-02 10:27:54 +03:00
|
|
|
|
2020-07-16 03:20:47 +03:00
|
|
|
if *chatDbFile != "" {
|
|
|
|
config.Config.ChatDatabaseFilePath = *chatDbFile
|
|
|
|
} else if config.Config.ChatDatabaseFilePath == "" {
|
|
|
|
config.Config.ChatDatabaseFilePath = "chat.db"
|
|
|
|
}
|
|
|
|
|
2020-08-27 18:50:27 +03:00
|
|
|
go metrics.Start()
|
2020-08-27 10:37:32 +03:00
|
|
|
|
2020-06-23 04:11:56 +03:00
|
|
|
// starts the core
|
|
|
|
if err := core.Start(); err != nil {
|
2020-07-07 07:27:31 +03:00
|
|
|
log.Error("failed to start the core package")
|
2020-06-23 04:11:56 +03:00
|
|
|
panic(err)
|
2020-06-10 11:16:17 +03:00
|
|
|
}
|
2020-06-02 10:27:54 +03:00
|
|
|
|
2020-06-23 04:11:56 +03:00
|
|
|
if err := router.Start(); err != nil {
|
2020-07-07 07:27:31 +03:00
|
|
|
log.Error("failed to start/run the router")
|
2020-06-23 04:11:56 +03:00
|
|
|
panic(err)
|
2020-06-16 02:27:58 +03:00
|
|
|
}
|
2020-07-07 07:27:31 +03:00
|
|
|
|
2020-06-02 10:27:54 +03:00
|
|
|
}
|
2020-06-24 22:55:49 +03:00
|
|
|
|
|
|
|
//getVersion gets the version string
|
|
|
|
func getVersion() string {
|
|
|
|
return fmt.Sprintf("Owncast v%s-%s (%s)", BuildVersion, BuildType, GitCommit)
|
|
|
|
}
|
2020-07-07 07:27:31 +03:00
|
|
|
|
|
|
|
func configureLogging() {
|
|
|
|
log.SetFormatter(&log.TextFormatter{
|
|
|
|
FullTimestamp: true,
|
|
|
|
})
|
|
|
|
}
|