grepmax 0.7.32 → 0.7.33
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/commands/serve.js
CHANGED
|
@@ -380,6 +380,7 @@ exports.serve = new commander_1.Command("serve")
|
|
|
380
380
|
// Ensure we exit if server fails to start
|
|
381
381
|
process.exit(1);
|
|
382
382
|
});
|
|
383
|
+
server.setTimeout(60000); // 60s request timeout
|
|
383
384
|
server.listen(port, () => {
|
|
384
385
|
const address = server.address();
|
|
385
386
|
const actualPort = typeof address === "object" && address ? address.port : port;
|
|
@@ -105,7 +105,12 @@ function startWatcher(opts) {
|
|
|
105
105
|
clearTimeout(debounceTimer);
|
|
106
106
|
debounceTimer = setTimeout(() => processBatch(), DEBOUNCE_MS);
|
|
107
107
|
};
|
|
108
|
-
const
|
|
108
|
+
const taskTimeoutMs = (() => {
|
|
109
|
+
var _a;
|
|
110
|
+
const fromEnv = Number.parseInt((_a = process.env.GMAX_WORKER_TASK_TIMEOUT_MS) !== null && _a !== void 0 ? _a : "", 10);
|
|
111
|
+
return Number.isFinite(fromEnv) && fromEnv > 0 ? fromEnv : 120000;
|
|
112
|
+
})();
|
|
113
|
+
const BATCH_TIMEOUT_MS = Math.max(Math.ceil(taskTimeoutMs * 1.5), 120000);
|
|
109
114
|
const processBatch = () => __awaiter(this, void 0, void 0, function* () {
|
|
110
115
|
var _a;
|
|
111
116
|
if (closed || processing || pending.size === 0)
|
|
@@ -95,13 +95,9 @@ function postJSON(path, body) {
|
|
|
95
95
|
/**
|
|
96
96
|
* Check if MLX server is reachable. Caches result for CHECK_INTERVAL_MS.
|
|
97
97
|
*/
|
|
98
|
-
function
|
|
98
|
+
function checkHealth() {
|
|
99
99
|
return __awaiter(this, void 0, void 0, function* () {
|
|
100
|
-
|
|
101
|
-
if (mlxAvailable !== null && now - lastCheck < CHECK_INTERVAL_MS) {
|
|
102
|
-
return mlxAvailable;
|
|
103
|
-
}
|
|
104
|
-
const result = yield new Promise((resolve) => {
|
|
100
|
+
return new Promise((resolve) => {
|
|
105
101
|
const req = http.get({ hostname: MLX_HOST, port: MLX_PORT, path: "/health", timeout: 2000 }, (res) => {
|
|
106
102
|
res.resume();
|
|
107
103
|
resolve(res.statusCode === 200);
|
|
@@ -112,6 +108,20 @@ function isMlxUp() {
|
|
|
112
108
|
resolve(false);
|
|
113
109
|
});
|
|
114
110
|
});
|
|
111
|
+
});
|
|
112
|
+
}
|
|
113
|
+
function isMlxUp() {
|
|
114
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
115
|
+
const now = Date.now();
|
|
116
|
+
if (mlxAvailable !== null && now - lastCheck < CHECK_INTERVAL_MS) {
|
|
117
|
+
return mlxAvailable;
|
|
118
|
+
}
|
|
119
|
+
let result = yield checkHealth();
|
|
120
|
+
// On first check (cold start), retry once after 3s — server may still be loading
|
|
121
|
+
if (!result && mlxAvailable === null) {
|
|
122
|
+
yield new Promise((r) => setTimeout(r, 3000));
|
|
123
|
+
result = yield checkHealth();
|
|
124
|
+
}
|
|
115
125
|
mlxAvailable = result;
|
|
116
126
|
lastCheck = now;
|
|
117
127
|
return result;
|
package/package.json
CHANGED