You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
RTSPtoWeb/RTSPtoWeb.go

43 lines
873 B
Go

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")
}