-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
95 lines (76 loc) · 2.27 KB
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
package main
import (
"flag"
"fmt"
"github.com/markbates/pkger"
"github.com/owncast/owncast/logging"
"github.com/sirupsen/logrus"
log "github.com/sirupsen/logrus"
"github.com/owncast/owncast/config"
"github.com/owncast/owncast/core"
"github.com/owncast/owncast/core/data"
"github.com/owncast/owncast/metrics"
"github.com/owncast/owncast/router"
)
// 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"
)
func main() {
configureLogging()
log.Infoln(getReleaseString())
// Enable bundling of admin assets
_ = pkger.Include("/admin")
configFile := flag.String("configFile", "config.yaml", "Config File full path. Defaults to current folder")
dbFile := flag.String("database", "", "Path to the database file.")
enableDebugOptions := flag.Bool("enableDebugFeatures", false, "Enable additional debugging options.")
enableVerboseLogging := flag.Bool("enableVerboseLogging", false, "Enable additional logging.")
flag.Parse()
if *enableDebugOptions {
logrus.SetReportCaller(true)
}
if *enableVerboseLogging {
log.SetLevel(log.TraceLevel)
} else {
log.SetLevel(log.InfoLevel)
}
if err := config.Load(*configFile, getReleaseString(), getVersionNumber()); err != nil {
panic(err)
}
config.Config.EnableDebugFeatures = *enableDebugOptions
if *dbFile != "" {
config.Config.DatabaseFilePath = *dbFile
} else if config.Config.DatabaseFilePath == "" {
config.Config.DatabaseFilePath = config.Config.GetDataFilePath()
}
go metrics.Start()
err := data.SetupPersistence()
if err != nil {
log.Fatalln("failed to open database", err)
}
// starts the core
if err := core.Start(); err != nil {
log.Fatalln("failed to start the core package", err)
}
if err := router.Start(); err != nil {
log.Fatalln("failed to start/run the router", err)
}
}
// getReleaseString gets the version string.
func getReleaseString() string {
return fmt.Sprintf("Owncast v%s-%s (%s)", BuildVersion, BuildType, GitCommit)
}
func getVersionNumber() string {
return BuildVersion
}
func configureLogging() {
logging.Setup()
log.SetFormatter(&log.TextFormatter{
FullTimestamp: true,
})
}