Refactor ipfs storage behind a standard interface
This commit is contained in:
19
main.go
19
main.go
@@ -5,11 +5,10 @@ import (
|
||||
"net/http"
|
||||
"strconv"
|
||||
|
||||
icore "github.com/ipfs/interface-go-ipfs-core"
|
||||
log "github.com/sirupsen/logrus"
|
||||
)
|
||||
|
||||
var ipfs icore.CoreAPI
|
||||
var storage ChunkStorage
|
||||
var configuration = getConfig()
|
||||
var server *Server
|
||||
|
||||
@@ -24,9 +23,11 @@ func main() {
|
||||
log.Println("Starting up. Please wait...")
|
||||
|
||||
if configuration.IPFS.Enabled {
|
||||
storage = &IPFSStorage{}
|
||||
(storage).Setup(configuration)
|
||||
|
||||
hlsDirectoryPath = configuration.PrivateHLSPath
|
||||
enableIPFS()
|
||||
go monitorVideoContent(hlsDirectoryPath, configuration, &ipfs)
|
||||
go monitorVideoContent(hlsDirectoryPath, configuration, storage)
|
||||
}
|
||||
|
||||
go startChatServer()
|
||||
@@ -34,16 +35,6 @@ func main() {
|
||||
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)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user