mirror of
https://github.com/TeaOSLab/EdgeAPI.git
synced 2025-12-23 05:16:37 +08:00
进程重启时,自动保存未保存的带宽统计数据到本地文件,以便于在重启后恢复
This commit is contained in:
@@ -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
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user