@episoda/cli 0.2.151 → 0.2.153
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/daemon/daemon-process.js +125 -36
- package/dist/daemon/daemon-process.js.map +1 -1
- package/dist/index.js +26 -0
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -3022,6 +3022,7 @@ async function startDaemon() {
|
|
|
3022
3022
|
throw new Error(`Daemon script not found: ${daemonScript}. Make sure CLI is built.`);
|
|
3023
3023
|
}
|
|
3024
3024
|
const logPath = path.join(configDir, "daemon.log");
|
|
3025
|
+
rotateDaemonLog(logPath);
|
|
3025
3026
|
const logFd = fs.openSync(logPath, "a");
|
|
3026
3027
|
const child = (0, import_child_process.spawn)("node", [daemonScript], {
|
|
3027
3028
|
detached: true,
|
|
@@ -3081,6 +3082,31 @@ async function stopDaemon(timeout = 5e3) {
|
|
|
3081
3082
|
return false;
|
|
3082
3083
|
}
|
|
3083
3084
|
}
|
|
3085
|
+
var MAX_LOG_SIZE_BYTES = 10 * 1024 * 1024;
|
|
3086
|
+
var MAX_LOG_FILES = 3;
|
|
3087
|
+
function rotateDaemonLog(logPath) {
|
|
3088
|
+
try {
|
|
3089
|
+
if (!fs.existsSync(logPath)) return;
|
|
3090
|
+
const stats = fs.statSync(logPath);
|
|
3091
|
+
if (stats.size < MAX_LOG_SIZE_BYTES) return;
|
|
3092
|
+
const oldestPath = `${logPath}.${MAX_LOG_FILES}`;
|
|
3093
|
+
if (fs.existsSync(oldestPath)) {
|
|
3094
|
+
fs.unlinkSync(oldestPath);
|
|
3095
|
+
}
|
|
3096
|
+
for (let i = MAX_LOG_FILES - 1; i >= 1; i--) {
|
|
3097
|
+
const src = `${logPath}.${i}`;
|
|
3098
|
+
const dst = `${logPath}.${i + 1}`;
|
|
3099
|
+
if (fs.existsSync(src)) {
|
|
3100
|
+
fs.renameSync(src, dst);
|
|
3101
|
+
}
|
|
3102
|
+
}
|
|
3103
|
+
if (fs.existsSync(logPath)) {
|
|
3104
|
+
fs.renameSync(logPath, `${logPath}.1`);
|
|
3105
|
+
}
|
|
3106
|
+
} catch (error) {
|
|
3107
|
+
console.warn("[DaemonManager] Log rotation failed:", error instanceof Error ? error.message : error);
|
|
3108
|
+
}
|
|
3109
|
+
}
|
|
3084
3110
|
|
|
3085
3111
|
// src/ipc/ipc-client.ts
|
|
3086
3112
|
var net = __toESM(require("net"));
|