gm-plugkit 2.0.1227 → 2.0.1228
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/plugkit-wasm-wrapper.js +24 -5
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "gm-plugkit",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.1228",
|
|
4
4
|
"description": "Bootstrap and daemon-spawn tool for gm plugkit binary. Downloads the correct platform binary, verifies SHA256, and starts the spool watcher daemon. Includes plugkit-wasm-wrapper for WASM-based spool watching.",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"bin": {
|
package/plugkit-wasm-wrapper.js
CHANGED
|
@@ -744,19 +744,36 @@ function isPortReachableSync(host, port, timeoutMs) {
|
|
|
744
744
|
s.on('connect', () => { done = true; s.destroy(); process.exit(0); });
|
|
745
745
|
s.on('error', () => { if (!done) process.exit(1); });
|
|
746
746
|
setTimeout(() => { if (!done) { s.destroy(); process.exit(1); } }, ${timeoutMs || 800});
|
|
747
|
-
`], { timeout: (timeoutMs || 800) + 2000 });
|
|
747
|
+
`], { timeout: (timeoutMs || 800) + 2000, windowsHide: true });
|
|
748
748
|
return r.status === 0;
|
|
749
749
|
}
|
|
750
750
|
|
|
751
|
-
let _acptoapiBoot = { spawned_at: 0, pid: null };
|
|
751
|
+
let _acptoapiBoot = { spawned_at: 0, pid: null, last_check_ts: 0, last_check_ok: false };
|
|
752
752
|
function ensureAcptoapi() {
|
|
753
753
|
const host = '127.0.0.1';
|
|
754
754
|
const port = 4800;
|
|
755
755
|
try {
|
|
756
|
-
|
|
757
|
-
|
|
756
|
+
// Two-strike port check: localhost connect can race against node cold-
|
|
757
|
+
// start on Windows. If the first check fails, retry once with a longer
|
|
758
|
+
// timeout before declaring the port dead. iter9 sniff reported 29
|
|
759
|
+
// bootstrap.acptoapi.spawned events in 30m despite acptoapi being alive
|
|
760
|
+
// on :4800 (HTTP 200) — the check flaked under heartbeat-tick load.
|
|
761
|
+
let reachable = isPortReachableSync(host, port, 1500);
|
|
762
|
+
if (!reachable) {
|
|
763
|
+
reachable = isPortReachableSync(host, port, 3000);
|
|
764
|
+
}
|
|
765
|
+
if (reachable) {
|
|
766
|
+
const wasDown = _acptoapiBoot.spawned_at > 0 || !_acptoapiBoot.last_check_ok;
|
|
767
|
+
_acptoapiBoot = { spawned_at: 0, pid: null, status: 'already-running', last_check_ts: Date.now(), last_check_ok: true };
|
|
768
|
+
// Only log on transitions (down → up) so the heartbeat doesn't spam
|
|
769
|
+
// bootstrap.jsonl every 60s with redundant "alive" events.
|
|
770
|
+
if (wasDown) {
|
|
771
|
+
logEvent('bootstrap', 'acptoapi.heartbeat-ok', { port, transition: 'down-to-up' });
|
|
772
|
+
}
|
|
758
773
|
return;
|
|
759
774
|
}
|
|
775
|
+
_acptoapiBoot.last_check_ok = false;
|
|
776
|
+
_acptoapiBoot.last_check_ts = Date.now();
|
|
760
777
|
if (_acptoapiBoot.spawned_at && Date.now() - _acptoapiBoot.spawned_at < 30000) {
|
|
761
778
|
return;
|
|
762
779
|
}
|
|
@@ -769,7 +786,9 @@ function ensureAcptoapi() {
|
|
|
769
786
|
shell: false,
|
|
770
787
|
});
|
|
771
788
|
child.unref();
|
|
772
|
-
_acptoapiBoot =
|
|
789
|
+
_acptoapiBoot.spawned_at = Date.now();
|
|
790
|
+
_acptoapiBoot.pid = child.pid;
|
|
791
|
+
_acptoapiBoot.status = 'spawned';
|
|
773
792
|
logEvent('bootstrap', 'acptoapi.spawned', { pid: child.pid, port });
|
|
774
793
|
} catch (e) {
|
|
775
794
|
logEvent('bootstrap', 'acptoapi.spawn-failed', { error: e && e.message });
|