This commit is contained in:
2025-10-19 10:15:11 +02:00
parent 26bfd17683
commit 0159c68fa5
17 changed files with 1078 additions and 523 deletions

View File

@@ -32,31 +32,14 @@ func FreqHztoMhz(freq string) string {
return strconv.FormatFloat(frequency, 'f', 6, 64)
}
func CheckSignal(TCPClient *TCPClient, TCPServer *TCPServer, FlexClient *FlexClient, fRepo *FlexDXClusterRepository, cRepo *Log4OMContactsRepository) {
func CheckSignal(tcpClient *TCPClient, tcpServer *TCPServer, flexClient *FlexClient, flexRepo *FlexDXClusterRepository, contactRepo *Log4OMContactsRepository) {
sigchan := make(chan os.Signal, 1)
signal.Notify(sigchan, os.Interrupt, syscall.SIGTERM)
sigCh := make(chan os.Signal, 1)
signal.Notify(sigCh, syscall.SIGHUP, syscall.SIGINT, syscall.SIGQUIT, syscall.SIGTERM)
<-sigchan
// Gracely closing all connextions if signal is received
for sig := range sigCh {
Log.Infof("received signal: %v, shutting down all connections.", sig)
TCPClient.Close()
TCPServer.Conn.Close()
FlexClient.Conn.Close()
if err := fRepo.db.Close(); err != nil {
Log.Error("failed to close the database connection properly")
os.Exit(1)
}
if err := cRepo.db.Close(); err != nil {
Log.Error("failed to close Log4OM database connection properly")
os.Exit(1)
}
os.Exit(0)
}
GracefulShutdown(tcpClient, tcpServer, flexClient, flexRepo, contactRepo)
os.Exit(0)
}
func SendUDPMessage(data []byte) {