grepmax 0.13.2 → 0.13.3
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/lib/llm/server.js
CHANGED
|
@@ -52,7 +52,7 @@ const config_2 = require("./config");
|
|
|
52
52
|
const HEALTH_TIMEOUT_MS = 2000;
|
|
53
53
|
const POLL_INTERVAL_MS = 500;
|
|
54
54
|
const STOP_GRACE_MS = 5000;
|
|
55
|
-
const
|
|
55
|
+
const DEFAULT_IDLE_CHECK_INTERVAL_MS = 5 * 60 * 1000;
|
|
56
56
|
class LlmServer {
|
|
57
57
|
constructor() {
|
|
58
58
|
this.lastRequestTime = 0;
|
|
@@ -82,8 +82,13 @@ class LlmServer {
|
|
|
82
82
|
/** Start llama-server, poll until ready, start idle watchdog. */
|
|
83
83
|
start() {
|
|
84
84
|
return __awaiter(this, void 0, void 0, function* () {
|
|
85
|
-
if (yield this.healthy())
|
|
85
|
+
if (yield this.healthy()) {
|
|
86
|
+
// Adopt an existing server (e.g. after daemon crash + restart)
|
|
87
|
+
this.lastRequestTime = Date.now();
|
|
88
|
+
this.startTime = Date.now();
|
|
89
|
+
this.startIdleWatchdog();
|
|
86
90
|
return;
|
|
91
|
+
}
|
|
87
92
|
// Validate binary
|
|
88
93
|
const binary = this.config.binary;
|
|
89
94
|
try {
|
|
@@ -215,6 +220,7 @@ class LlmServer {
|
|
|
215
220
|
startIdleWatchdog() {
|
|
216
221
|
this.stopIdleWatchdog();
|
|
217
222
|
const timeoutMs = this.config.idleTimeoutMin * 60 * 1000;
|
|
223
|
+
const checkInterval = Math.min(DEFAULT_IDLE_CHECK_INTERVAL_MS, timeoutMs);
|
|
218
224
|
this.idleTimer = setInterval(() => __awaiter(this, void 0, void 0, function* () {
|
|
219
225
|
if (this.lastRequestTime === 0)
|
|
220
226
|
return;
|
|
@@ -222,7 +228,7 @@ class LlmServer {
|
|
|
222
228
|
console.log(`[llm] Server idle for ${this.config.idleTimeoutMin}min, shutting down`);
|
|
223
229
|
yield this.stop();
|
|
224
230
|
}
|
|
225
|
-
}),
|
|
231
|
+
}), checkInterval);
|
|
226
232
|
this.idleTimer.unref();
|
|
227
233
|
}
|
|
228
234
|
stopIdleWatchdog() {
|
package/package.json
CHANGED