Actually fix race condition that happens in production. I think.
This commit is contained in:
6
main.go
6
main.go
@@ -22,9 +22,11 @@ var stats *Stats
|
|||||||
var usingExternalStorage = false
|
var usingExternalStorage = false
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
|
// logrus.SetReportCaller(true)
|
||||||
log.StandardLogger().Printf("Owncast v%s/%s (%s)", BuildVersion, BuildType, GitCommit)
|
log.StandardLogger().Printf("Owncast v%s/%s (%s)", BuildVersion, BuildType, GitCommit)
|
||||||
|
|
||||||
checkConfig(configuration)
|
checkConfig(configuration)
|
||||||
|
resetDirectories(configuration)
|
||||||
|
|
||||||
stats = getSavedStats()
|
stats = getSavedStats()
|
||||||
stats.Setup()
|
stats.Setup()
|
||||||
@@ -42,15 +44,13 @@ func main() {
|
|||||||
go monitorVideoContent(configuration.PrivateHLSPath, configuration, storage)
|
go monitorVideoContent(configuration.PrivateHLSPath, configuration, storage)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
createInitialOfflineState()
|
||||||
go startRTMPService()
|
go startRTMPService()
|
||||||
|
|
||||||
resetDirectories(configuration)
|
|
||||||
startWebServer()
|
startWebServer()
|
||||||
}
|
}
|
||||||
|
|
||||||
func startWebServer() {
|
func startWebServer() {
|
||||||
// log.SetFlags(log.Lshortfile)
|
|
||||||
|
|
||||||
// websocket server
|
// websocket server
|
||||||
server = NewServer("/entry")
|
server = NewServer("/entry")
|
||||||
go server.Listen()
|
go server.Listen()
|
||||||
|
|||||||
@@ -88,6 +88,9 @@ func monitorVideoContent(pathToMonitor string, configuration Config, storage Chu
|
|||||||
case event := <-w.Event:
|
case event := <-w.Event:
|
||||||
|
|
||||||
relativePath := getRelativePathFromAbsolutePath(event.Path)
|
relativePath := getRelativePathFromAbsolutePath(event.Path)
|
||||||
|
if path.Ext(relativePath) == ".tmp" {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
// Ignore removals
|
// Ignore removals
|
||||||
if event.Op == watcher.Remove {
|
if event.Op == watcher.Remove {
|
||||||
@@ -130,11 +133,13 @@ func monitorVideoContent(pathToMonitor string, configuration Config, storage Chu
|
|||||||
}()
|
}()
|
||||||
|
|
||||||
// Watch the hls segment storage folder recursively for changes.
|
// Watch the hls segment storage folder recursively for changes.
|
||||||
|
w.FilterOps(watcher.Write, watcher.Rename, watcher.Create)
|
||||||
|
|
||||||
if err := w.AddRecursive(pathToMonitor); err != nil {
|
if err := w.AddRecursive(pathToMonitor); err != nil {
|
||||||
log.Fatalln(err)
|
log.Fatalln(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := w.Start(time.Millisecond * 100); err != nil {
|
if err := w.Start(time.Millisecond * 200); err != nil {
|
||||||
log.Fatalln(err)
|
log.Fatalln(err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
3
utils.go
3
utils.go
@@ -74,6 +74,9 @@ func resetDirectories(configuration Config) {
|
|||||||
os.MkdirAll(path.Join(configuration.PublicHLSPath, strconv.Itoa(0)), 0777)
|
os.MkdirAll(path.Join(configuration.PublicHLSPath, strconv.Itoa(0)), 0777)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
func createInitialOfflineState() {
|
||||||
// Provide default files
|
// Provide default files
|
||||||
showStreamOfflineState(configuration)
|
showStreamOfflineState(configuration)
|
||||||
if !fileExists("webroot/thumbnail.png") {
|
if !fileExists("webroot/thumbnail.png") {
|
||||||
|
|||||||
Reference in New Issue
Block a user