owncast/main.go

55 lines
1.0 KiB
Go
Raw Normal View History

2020-05-24 02:57:49 +02:00
package main
import (
"net/http"
2020-06-02 01:53:31 +02:00
"strconv"
2020-05-24 02:57:49 +02:00
icore "github.com/ipfs/interface-go-ipfs-core"
2020-05-24 02:57:49 +02:00
log "github.com/sirupsen/logrus"
)
var ipfs icore.CoreAPI
2020-06-02 01:53:31 +02:00
var configuration = getConfig()
2020-05-30 03:08:33 +02:00
func main() {
2020-06-02 01:53:31 +02:00
checkConfig(configuration)
// resetDirectories()
2020-05-30 03:08:33 +02:00
2020-06-02 01:53:31 +02:00
var hlsDirectoryPath = configuration.PublicHLSPath
2020-06-02 01:53:31 +02:00
log.Println("Starting up. Please wait...")
if configuration.IPFS.Enabled {
hlsDirectoryPath = configuration.PrivateHLSPath
enableIPFS()
go monitorVideoContent(hlsDirectoryPath, configuration, &ipfs)
}
2020-05-24 02:57:49 +02:00
go startChatServer()
startRTMPService()
}
2020-06-02 01:53:31 +02:00
func enableIPFS() {
log.Println("Enabling IPFS support...")
ipfsInstance, node, _ := createIPFSInstance()
ipfs = *ipfsInstance
createIPFSDirectory(ipfsInstance, "./hls")
go startIPFSNode(ipfs, node)
}
func startChatServer() {
// log.SetFlags(log.Lshortfile)
// websocket server
server := NewServer("/entry")
go server.Listen()
// static files
http.Handle("/", http.FileServer(http.Dir("webroot")))
2020-06-02 01:53:31 +02:00
log.Fatal(http.ListenAndServe(":"+strconv.Itoa(configuration.WebServerPort), nil))
}