forked from deepch/RTSPtoWeb
-
Notifications
You must be signed in to change notification settings - Fork 0
/
RTSPtoWeb.go
42 lines (39 loc) · 873 Bytes
/
RTSPtoWeb.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
package main
import (
"os"
"os/signal"
"syscall"
"time"
"github.com/sirupsen/logrus"
)
func main() {
log.WithFields(logrus.Fields{
"module": "main",
"func": "main",
}).Info("Server CORE start")
go HTTPAPIServer()
go RTSPServer()
go Storage.StreamChannelRunAll()
signalChanel := make(chan os.Signal, 1)
done := make(chan bool, 1)
signal.Notify(signalChanel, syscall.SIGINT, syscall.SIGTERM)
go func() {
sig := <-signalChanel
log.WithFields(logrus.Fields{
"module": "main",
"func": "main",
}).Info("Server receive signal", sig)
done <- true
}()
log.WithFields(logrus.Fields{
"module": "main",
"func": "main",
}).Info("Server start success a wait signals")
<-done
Storage.StopAll()
time.Sleep(2 * time.Second)
log.WithFields(logrus.Fields{
"module": "main",
"func": "main",
}).Info("Server stop working by signal")
}