forked from langhuihui/monibuca
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
48 lines (43 loc) · 1.17 KB
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
package main
import (
"context"
"flag"
_ "net/http/pprof"
"os"
"os/signal"
"path/filepath"
"syscall"
. "github.com/Monibuca/engine/v3"
// _ "github.com/Monibuca/plugin-ffmpeg"
// _ "github.com/Monibuca/plugin-cluster"
_ "github.com/Monibuca/plugin-gateway/v3"
_ "github.com/Monibuca/plugin-gb28181/v3"
_ "github.com/Monibuca/plugin-hdl/v3"
_ "github.com/Monibuca/plugin-hls/v3"
_ "github.com/Monibuca/plugin-jessica/v3"
_ "github.com/Monibuca/plugin-logrotate/v3"
_ "github.com/Monibuca/plugin-record/v3"
_ "github.com/Monibuca/plugin-rtmp/v3"
_ "github.com/Monibuca/plugin-rtsp/v3"
_ "github.com/Monibuca/plugin-summary"
_ "github.com/Monibuca/plugin-ts/v3"
_ "github.com/Monibuca/plugin-webrtc/v3"
)
func main() {
addr := flag.String("c", "config.toml", "config file")
flag.Parse()
ctx, cancel := context.WithCancel(context.Background())
go waiter(cancel)
if _, err := os.Stat(*addr); err == nil {
Run(ctx, *addr)
} else {
Run(ctx, filepath.Join(filepath.Dir(os.Args[0]), *addr))
}
}
func waiter(cancel context.CancelFunc) {
sigc := make(chan os.Signal, 1)
signal.Notify(sigc, syscall.SIGINT, syscall.SIGTERM)
defer signal.Stop(sigc)
<-sigc
cancel()
}