2022-11-10 11:24:33 +00:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
2023-10-20 21:24:49 +00:00
|
|
|
"fmt"
|
2022-11-10 11:24:33 +00:00
|
|
|
"log"
|
|
|
|
"net/http"
|
2022-11-11 03:40:53 +00:00
|
|
|
"os"
|
2022-11-10 11:24:33 +00:00
|
|
|
)
|
|
|
|
|
2023-10-21 18:27:25 +00:00
|
|
|
const VERSION = "0.1.19"
|
2023-03-09 19:57:15 +00:00
|
|
|
|
2022-11-10 11:24:33 +00:00
|
|
|
func main() {
|
2023-10-20 21:12:09 +00:00
|
|
|
// Build initial configuration
|
2023-03-09 19:57:15 +00:00
|
|
|
c := &Config{
|
2023-10-20 21:12:09 +00:00
|
|
|
VersionMonitor: false,
|
2023-03-09 19:57:15 +00:00
|
|
|
Bind: ":47788",
|
|
|
|
ChunkSize: 3,
|
2023-03-15 17:21:44 +00:00
|
|
|
LookBehind: 3,
|
2023-03-09 19:57:15 +00:00
|
|
|
GoalBufferMin: 1,
|
|
|
|
GoalBufferMax: 4,
|
|
|
|
StreamIdleTime: 60,
|
|
|
|
ManagerIdleTime: 60,
|
2022-11-15 10:09:33 +00:00
|
|
|
}
|
|
|
|
|
2023-10-20 21:12:09 +00:00
|
|
|
// Parse arguments
|
|
|
|
for _, arg := range os.Args[1:] {
|
|
|
|
if arg == "-version-monitor" {
|
|
|
|
c.VersionMonitor = true
|
2023-10-20 21:24:49 +00:00
|
|
|
} else if arg == "-version" {
|
|
|
|
fmt.Print("go-vod " + VERSION)
|
2023-10-20 21:12:09 +00:00
|
|
|
return
|
|
|
|
} else {
|
2023-10-21 18:27:25 +00:00
|
|
|
c.FromFile(arg) // config file
|
2023-10-20 21:12:09 +00:00
|
|
|
}
|
2022-11-15 10:09:33 +00:00
|
|
|
}
|
|
|
|
|
2023-10-21 18:27:25 +00:00
|
|
|
// Auto detect ffmpeg and ffprobe
|
|
|
|
c.AutoDetect()
|
2023-04-10 23:44:39 +00:00
|
|
|
|
2023-10-21 18:27:25 +00:00
|
|
|
// Build HTTP server
|
2023-10-20 21:12:09 +00:00
|
|
|
log.Println("Starting go-vod " + VERSION + " on " + c.Bind)
|
|
|
|
handler := NewHandler(c)
|
2023-10-21 18:27:25 +00:00
|
|
|
handler.server = &http.Server{Addr: c.Bind, Handler: handler}
|
2022-11-10 11:24:33 +00:00
|
|
|
|
2023-10-21 18:27:25 +00:00
|
|
|
// Start server and wait for handler exit
|
|
|
|
handler.Start()
|
2022-11-10 11:24:33 +00:00
|
|
|
log.Println("Exiting VOD server")
|
2023-10-20 21:12:09 +00:00
|
|
|
|
|
|
|
// Exit with status code
|
|
|
|
os.Exit(handler.exitCode)
|
2022-11-10 11:24:33 +00:00
|
|
|
}
|