@costrict/csc 4.2.1 → 4.2.2
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/cli.js +3957 -3253
- package/dist/services/rawDump/batchWorker.js +47 -4
- package/package.json +4 -2
|
@@ -477,8 +477,8 @@ async function saveCoStrictCredentials(credentials) {
|
|
|
477
477
|
import { createRequire } from "module";
|
|
478
478
|
function getVersion() {
|
|
479
479
|
try {
|
|
480
|
-
if (typeof MACRO !== "undefined" && "4.2.
|
|
481
|
-
return "4.2.
|
|
480
|
+
if (typeof MACRO !== "undefined" && "4.2.2")
|
|
481
|
+
return "4.2.2";
|
|
482
482
|
} catch {}
|
|
483
483
|
try {
|
|
484
484
|
const require2 = createRequire(import.meta.url);
|
|
@@ -2680,9 +2680,22 @@ if (scriptPath2.endsWith("timerWorker.ts") || scriptPath2.endsWith("timerWorker.
|
|
|
2680
2680
|
var log6 = createLogger("batch");
|
|
2681
2681
|
var PARENT_PID = process.ppid;
|
|
2682
2682
|
var IS_WORKER_PROCESS = process.argv[1]?.includes("batchWorker") || false;
|
|
2683
|
+
function isParentAlive() {
|
|
2684
|
+
if (!IS_WORKER_PROCESS)
|
|
2685
|
+
return true;
|
|
2686
|
+
try {
|
|
2687
|
+
process.kill(PARENT_PID, 0);
|
|
2688
|
+
return true;
|
|
2689
|
+
} catch {
|
|
2690
|
+
return false;
|
|
2691
|
+
}
|
|
2692
|
+
}
|
|
2693
|
+
var stateLoaded = false;
|
|
2683
2694
|
function startBatchWorker() {
|
|
2684
2695
|
log6.info("batch worker started");
|
|
2685
|
-
loadAllState().
|
|
2696
|
+
loadAllState().then(() => {
|
|
2697
|
+
stateLoaded = true;
|
|
2698
|
+
}).catch((err) => {
|
|
2686
2699
|
log6.error("failed to load state", {
|
|
2687
2700
|
error: err instanceof Error ? err.message : String(err)
|
|
2688
2701
|
});
|
|
@@ -2704,6 +2717,36 @@ function startBatchWorker() {
|
|
|
2704
2717
|
}
|
|
2705
2718
|
});
|
|
2706
2719
|
startTimerWorker();
|
|
2720
|
+
startParentWatchdog();
|
|
2721
|
+
}
|
|
2722
|
+
function startParentWatchdog() {
|
|
2723
|
+
if (!IS_WORKER_PROCESS)
|
|
2724
|
+
return;
|
|
2725
|
+
const intervalMs = 5000;
|
|
2726
|
+
const maxParentGoneAliveMs = 60000;
|
|
2727
|
+
let parentGoneAt = null;
|
|
2728
|
+
setInterval(() => {
|
|
2729
|
+
if (isParentAlive()) {
|
|
2730
|
+
parentGoneAt = null;
|
|
2731
|
+
return;
|
|
2732
|
+
}
|
|
2733
|
+
if (parentGoneAt === null) {
|
|
2734
|
+
parentGoneAt = Date.now();
|
|
2735
|
+
}
|
|
2736
|
+
const goneMs = Date.now() - parentGoneAt;
|
|
2737
|
+
const canExitSafely = stateLoaded && state_task.incomplete === 0;
|
|
2738
|
+
const graceExpired = goneMs >= maxParentGoneAliveMs;
|
|
2739
|
+
if (canExitSafely || graceExpired) {
|
|
2740
|
+
log6.info("parent process gone, exiting batch worker", {
|
|
2741
|
+
parentPid: PARENT_PID,
|
|
2742
|
+
workerPid: process.pid,
|
|
2743
|
+
reason: canExitSafely ? "no incomplete tasks" : "grace period expired",
|
|
2744
|
+
goneMs,
|
|
2745
|
+
incompleteTasks: state_task.incomplete
|
|
2746
|
+
});
|
|
2747
|
+
process.exit(0);
|
|
2748
|
+
}
|
|
2749
|
+
}, intervalMs);
|
|
2707
2750
|
}
|
|
2708
2751
|
var scriptPath3 = process.argv[1] || "";
|
|
2709
2752
|
if (scriptPath3.endsWith("batchWorker.ts") || scriptPath3.endsWith("batchWorker.js")) {
|
|
@@ -2713,5 +2756,5 @@ export {
|
|
|
2713
2756
|
startBatchWorker
|
|
2714
2757
|
};
|
|
2715
2758
|
|
|
2716
|
-
//# debugId=
|
|
2759
|
+
//# debugId=5B5356A9971433D364756E2164756E21
|
|
2717
2760
|
//# sourceMappingURL=batchWorker.js.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@costrict/csc",
|
|
3
|
-
"version": "4.2.
|
|
3
|
+
"version": "4.2.2",
|
|
4
4
|
"description": "costrict",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"author": "costrict",
|
|
@@ -228,6 +228,8 @@
|
|
|
228
228
|
"zod": "^4.4.3"
|
|
229
229
|
},
|
|
230
230
|
"overrides": {
|
|
231
|
-
"tmp": "^0.2.7"
|
|
231
|
+
"tmp": "^0.2.7",
|
|
232
|
+
"@grpc/grpc-js": "^1.14.4",
|
|
233
|
+
"esbuild": ">=0.28.1"
|
|
232
234
|
}
|
|
233
235
|
}
|