🌐 AI搜索 & 代理 主页
Skip to content

Commit 65e212b

Browse files
committed
Replace curl with native fetch for health checks
1 parent 2469a5e commit 65e212b

File tree

1 file changed

+12
-7
lines changed

1 file changed

+12
-7
lines changed

cli/bin/postgres-ai.ts

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -248,15 +248,20 @@ mon
248248
allHealthy = true;
249249
for (const service of services) {
250250
try {
251-
const { stdout } = await execPromise(
252-
`curl -sf -o /dev/null -w "%{http_code}" ${service.url}`,
253-
{ timeout: 5000 }
254-
);
255-
const code = stdout.trim();
256-
if (code === "200") {
251+
// Use native fetch instead of requiring curl to be installed
252+
const controller = new AbortController();
253+
const timeoutId = setTimeout(() => controller.abort(), 5000);
254+
255+
const response = await fetch(service.url, {
256+
signal: controller.signal,
257+
method: 'GET',
258+
});
259+
clearTimeout(timeoutId);
260+
261+
if (response.status === 200) {
257262
console.log(`✓ ${service.name}: healthy`);
258263
} else {
259-
console.log(`✗ ${service.name}: unhealthy (HTTP ${code})`);
264+
console.log(`✗ ${service.name}: unhealthy (HTTP ${response.status})`);
260265
allHealthy = false;
261266
}
262267
} catch (error) {

0 commit comments

Comments
 (0)