-
Notifications
You must be signed in to change notification settings - Fork 17
Expand file tree
/
Copy pathseal.go
More file actions
80 lines (65 loc) · 1.42 KB
/
seal.go
File metadata and controls
80 lines (65 loc) · 1.42 KB
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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
package main
import (
"flag"
"log"
"os"
"runtime"
"seal/conf"
"sync"
"time"
"github.com/calabashdad/utiltools"
)
const sealVersion = "seal: 1.0.0 build-2018052801"
var (
configFile = flag.String("c", "./seal.yaml", "configure filename")
showVersion = flag.Bool("v", false, "show version of seal")
)
var (
gGuards sync.WaitGroup
)
func init() {
log.SetFlags(log.Lshortfile | log.Ldate | log.Lmicroseconds)
flag.Parse()
}
func main() {
defer func() {
if err := recover(); err != nil {
log.Println(utiltools.PanicTrace())
time.Sleep(1 * time.Second)
}
}()
if len(os.Args) < 2 {
log.Println("Show usage : ./seal --help.")
return
}
if *showVersion {
log.Println(sealVersion)
return
}
err := conf.GlobalConfInfo.Loads(*configFile)
if err != nil {
log.Println("conf loads failed.err=", err)
return
}
log.Printf("load conf file success, conf=%+v\n", conf.GlobalConfInfo)
cpuNums := runtime.NumCPU()
if 0 == conf.GlobalConfInfo.System.CPUNums {
runtime.GOMAXPROCS(cpuNums)
log.Println("app run on auto cpu nums=", cpuNums)
} else {
runtime.GOMAXPROCS(int(conf.GlobalConfInfo.System.CPUNums))
log.Println("app run on cpu nums set by config, num=", conf.GlobalConfInfo.System.CPUNums)
}
gGuards.Add(1)
if true {
rtmpSrv := rtmpServer{}
go rtmpSrv.Start()
}
gGuards.Add(1)
if true {
hlsSrv := hlsServer{}
go hlsSrv.Start()
}
gGuards.Wait()
log.Println("seal quit gracefully.")
}