Will now run as a self-contained IPFS node

This commit is contained in:
Gabe Kangas
2020-06-01 12:15:07 -07:00
parent af698063bd
commit bf5d792ac0
6 changed files with 870 additions and 66 deletions

45
main.go
View File

@@ -5,19 +5,43 @@ import (
"net"
"net/http"
icore "github.com/ipfs/interface-go-ipfs-core"
log "github.com/sirupsen/logrus"
"github.com/yutopp/go-rtmp"
)
var ipfs icore.CoreAPI
func main() {
createIPFSDirectory()
resetDirectories()
touch("hls/stream.m3u8")
go monitorVideoContent("./hls/")
ipfsInstance, node, _ := createIPFSInstance()
ipfs = *ipfsInstance
createIPFSDirectory(ipfsInstance, "./hls")
// touch("hls/stream.m3u8")
go startIPFSNode(ipfs, node)
go monitorVideoContent("./hls/", ipfsInstance)
go startChatServer()
startRTMPService()
}
func startChatServer() {
// log.SetFlags(log.Lshortfile)
// websocket server
server := NewServer("/entry")
go server.Listen()
// static files
http.Handle("/", http.FileServer(http.Dir("webroot")))
log.Fatal(http.ListenAndServe(":8080", nil))
}
func startRTMPService() {
tcpAddr, err := net.ResolveTCPAddr("tcp", ":1935")
if err != nil {
log.Panicf("Failed: %+v", err)
@@ -51,16 +75,3 @@ func main() {
}
}
func startChatServer() {
// log.SetFlags(log.Lshortfile)
// websocket server
server := NewServer("/entry")
go server.Listen()
// static files
http.Handle("/", http.FileServer(http.Dir("webroot")))
log.Fatal(http.ListenAndServe(":8080", nil))
}