mirror of
https://github.com/hotyue/IP-Sentinel.git
synced 2026-06-02 01:39:35 +08:00
fix(core): 引入 flock 排他锁,彻底解决 Cron 任务重入导致的内存雪崩与 Fork 炸弹
This commit is contained in:
@@ -15,6 +15,14 @@ if [ ! -f "$CONFIG_FILE" ]; then
|
||||
fi
|
||||
source "$CONFIG_FILE"
|
||||
|
||||
# ================== [新增: 文件排他锁,防止并发重入引发内存雪崩] ==================
|
||||
exec 200>"/tmp/ip_sentinel_runner.lock"
|
||||
if ! flock -n 200; then
|
||||
echo "[$(date)] ⚠️ 上一轮巡逻任务尚未结束,本次触发自动取消。" >> "$LOG_FILE"
|
||||
exit 0
|
||||
fi
|
||||
# ==================================================================================
|
||||
|
||||
# 2. 全局日志写入函数 (导出给子进程共享使用,v3.4.0 引入版本探针)
|
||||
log() {
|
||||
local module=$1
|
||||
|
||||
Reference in New Issue
Block a user