feat: add structured logging, process watchdog, and systemd hardening
- Add lib/logger.js: timestamped structured logging with 5MB x 5 file rotation - Add lib/watchdog.js: generic child process supervisor with rate-limited restarts - Enhance client.js: WS ping/pong liveness detection, uncaughtException/unhandledRejection handlers, systemd sd-notify integration - Refactor frpc.js: FrpcManager now delegates to Watchdog instead of manual spawn/exit - Enhance install.sh: environment file, log directory, systemd resource limits, security hardening, WatchdogSec=60 - Replace all console.log/warn/error with structured logger across modules Made-with: Cursor
This commit is contained in:
@@ -26,7 +26,8 @@ function load() {
|
||||
return Object.assign({}, DEFAULTS, JSON.parse(raw));
|
||||
}
|
||||
} catch (e) {
|
||||
console.error('[config] 读取配置失败,使用默认值:', e.message);
|
||||
const log = require('./logger');
|
||||
log.error('config', '读取配置失败,使用默认值:', e.message);
|
||||
}
|
||||
return Object.assign({}, DEFAULTS);
|
||||
}
|
||||
@@ -36,7 +37,8 @@ function save(data) {
|
||||
fs.mkdirSync(CONFIG_DIR, { recursive: true });
|
||||
fs.writeFileSync(CONFIG_FILE, JSON.stringify(data, null, 2), 'utf8');
|
||||
} catch (e) {
|
||||
console.error('[config] 写入配置失败:', e.message);
|
||||
const log = require('./logger');
|
||||
log.error('config', '写入配置失败:', e.message);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user