You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
56 lines
1.1 KiB
56 lines
1.1 KiB
package main |
|
|
|
import ( |
|
"net/http" |
|
"strconv" |
|
|
|
icore "github.com/ipfs/interface-go-ipfs-core" |
|
log "github.com/sirupsen/logrus" |
|
) |
|
|
|
var ipfs icore.CoreAPI |
|
var configuration = getConfig() |
|
|
|
func main() { |
|
checkConfig(configuration) |
|
// resetDirectories() |
|
|
|
var hlsDirectoryPath = configuration.PublicHLSPath |
|
|
|
log.Println("Starting up. Please wait...") |
|
|
|
if configuration.IPFS.Enabled { |
|
hlsDirectoryPath = configuration.PrivateHLSPath |
|
enableIPFS() |
|
go monitorVideoContent(hlsDirectoryPath, configuration, &ipfs) |
|
} |
|
|
|
go startChatServer() |
|
|
|
startRTMPService() |
|
} |
|
|
|
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"))) |
|
|
|
log.Printf("Starting public web server on port %d", configuration.WebServerPort) |
|
|
|
log.Fatal(http.ListenAndServe(":"+strconv.Itoa(configuration.WebServerPort), nil)) |
|
}
|
|
|