进程重启时,自动保存未保存的带宽统计数据到本地文件,以便于在重启后恢复

This commit is contained in:
GoEdgeLab
2024-04-13 17:14:58 +08:00
parent 06ddd03dd8
commit 2f67f2fa6f
2 changed files with 46 additions and 0 deletions

View File

@@ -35,11 +35,13 @@ import (
"net"
"os"
"os/exec"
"os/signal"
"runtime"
"sort"
"strconv"
"strings"
"sync"
"syscall"
"time"
// grpc decompression
@@ -92,6 +94,9 @@ func (this *APINode) Start() {
return
}
// 监听信号
this.listenSignals()
// 启动IP库
this.setProgress("IP_LIBRARY", "开始初始化IP库")
remotelogs.Println("API_NODE", "initializing ip library ...")
@@ -921,3 +926,16 @@ func (this *APINode) setupTimeZone() {
}
}
}
// 监听一些信号
func (this *APINode) listenSignals() {
var queue = make(chan os.Signal, 8)
signal.Notify(queue, syscall.SIGTERM, syscall.SIGINT, syscall.SIGKILL, syscall.SIGQUIT)
goman.New(func() {
for range queue {
events.Notify(events.EventQuit)
os.Exit(0)
return
}
})
}