1
0
mirror of https://gitlab.crans.org/nounous/ghostream.git synced 2024-12-22 16:12:19 +00:00
ghostream/main.go

62 lines
1.7 KiB
Go
Raw Normal View History

2020-09-28 15:36:40 +00:00
//go:generate pkger
2020-10-09 20:36:02 +00:00
// Package main provides the full-featured server with configuration loading
// and communication between routines.
2020-09-21 15:29:50 +00:00
package main
import (
2020-11-09 16:18:37 +00:00
"gitlab.crans.org/nounous/ghostream/stream/ovenmediaengine"
2020-09-21 17:59:41 +00:00
"log"
2020-11-07 14:02:09 +00:00
"github.com/pkg/profile"
2020-09-22 09:42:57 +00:00
"gitlab.crans.org/nounous/ghostream/auth"
"gitlab.crans.org/nounous/ghostream/internal/config"
2020-09-21 19:38:11 +00:00
"gitlab.crans.org/nounous/ghostream/internal/monitoring"
"gitlab.crans.org/nounous/ghostream/messaging"
2020-09-30 13:07:36 +00:00
"gitlab.crans.org/nounous/ghostream/stream/forwarding"
2020-09-27 09:14:22 +00:00
"gitlab.crans.org/nounous/ghostream/stream/srt"
2020-10-13 16:04:00 +00:00
"gitlab.crans.org/nounous/ghostream/stream/telnet"
"gitlab.crans.org/nounous/ghostream/stream/webrtc"
"gitlab.crans.org/nounous/ghostream/transcoder"
2020-09-21 15:47:31 +00:00
"gitlab.crans.org/nounous/ghostream/web"
2020-09-21 15:29:50 +00:00
)
func main() {
2020-11-07 14:02:09 +00:00
// TODO Don't always profile if not needed
defer profile.Start().Stop()
2020-10-05 09:38:17 +00:00
// Configure logger
log.SetFlags(log.Ldate | log.Ltime | log.Lshortfile)
2020-09-21 17:59:41 +00:00
// Load configuration
cfg, err := config.Load()
if err != nil {
log.Fatalln("Failed to load configuration:", err)
2020-09-21 17:59:41 +00:00
}
2020-09-22 10:54:12 +00:00
// Init authentification
authBackend, err := auth.New(&cfg.Auth)
if err != nil {
log.Fatalln("Failed to load authentification backend:", err)
}
2020-10-09 20:06:30 +00:00
if authBackend != nil {
defer authBackend.Close()
}
2020-09-22 10:54:12 +00:00
2020-10-17 16:22:06 +00:00
// Init streams messaging
streams := messaging.New()
// Start routines
go transcoder.Init(streams, &cfg.Transcoder)
2020-10-18 09:06:54 +00:00
go forwarding.Serve(streams, cfg.Forwarding)
go monitoring.Serve(&cfg.Monitoring)
2020-11-09 16:18:37 +00:00
go ovenmediaengine.Serve(streams, &cfg.OME)
2020-10-17 16:22:06 +00:00
go srt.Serve(streams, authBackend, &cfg.Srt)
go telnet.Serve(streams, &cfg.Telnet)
2020-11-09 16:18:37 +00:00
go web.Serve(streams, &cfg.Web, &cfg.OME)
2020-10-19 19:45:23 +00:00
go webrtc.Serve(streams, &cfg.WebRTC)
2020-09-21 19:33:32 +00:00
2020-09-21 19:05:45 +00:00
// Wait for routines
select {}
2020-09-21 15:29:50 +00:00
}