bom-pi 0.0.8 → 0.0.9
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/package.json +1 -1
- package/packages/core/src/daemon.mjs +13 -1
package/package.json
CHANGED
|
@@ -2281,7 +2281,19 @@ try {
|
|
|
2281
2281
|
httpServer.listen(httpPort, '127.0.0.1', () => { httpServer.off('error', rej); res(); });
|
|
2282
2282
|
});
|
|
2283
2283
|
} catch (e) {
|
|
2284
|
-
|
|
2284
|
+
if (e?.code === 'EADDRINUSE') {
|
|
2285
|
+
// thường là daemon nền do CLI khởi động (hoặc systemd) đang sống ở đó — nói rõ thay vì bảo đổi port
|
|
2286
|
+
let who = 'không xác định';
|
|
2287
|
+
try {
|
|
2288
|
+
const r = await fetch(`http://127.0.0.1:${httpPort}/healthz`, { signal: AbortSignal.timeout(1000) });
|
|
2289
|
+
const j = await r.json().catch(() => ({}));
|
|
2290
|
+
if (j?.name === 'bom-core') who = `bom-core khác (protocol ${j?.protocol ?? '?'}, pid xem 'bom-pi daemon status')`;
|
|
2291
|
+
} catch { /* không trả lời — không phải bom-core */ }
|
|
2292
|
+
log(`từ chối khởi động: HTTP 127.0.0.1:${httpPort} đã bị chiếm bởi ${who}`);
|
|
2293
|
+
log(`đang muốn chạy daemon này? dọn cái cũ trước: bom-pi daemon stop (hoặc: systemctl --user stop bom-core)`);
|
|
2294
|
+
} else {
|
|
2295
|
+
log(`không nghe được HTTP 127.0.0.1:${httpPort}: ${e.code ?? e.message} — chạy với --port <port khác>`);
|
|
2296
|
+
}
|
|
2285
2297
|
if (listening) await rm(socketPath, { force: true }); // dọn socket đã mở, không để lại mồ
|
|
2286
2298
|
process.exit(1);
|
|
2287
2299
|
}
|