nexrall-code 0.5.183 → 0.5.185
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/index.js +8187 -3422
- package/nex-watch.js +16 -11
- package/package.json +1 -1
package/nex-watch.js
CHANGED
|
@@ -43,9 +43,8 @@
|
|
|
43
43
|
|
|
44
44
|
import { spawnSync } from 'child_process';
|
|
45
45
|
|
|
46
|
-
const MAX_RETRIES =
|
|
47
|
-
? Math.floor(Number(process.env.NEX_WATCH_MAX_RETRIES))
|
|
48
|
-
: 5;
|
|
46
|
+
const MAX_RETRIES =
|
|
47
|
+
Number(process.env.NEX_WATCH_MAX_RETRIES) > 0 ? Math.floor(Number(process.env.NEX_WATCH_MAX_RETRIES)) : 5;
|
|
49
48
|
const NEX_BIN = process.env.NEX_WATCH_BIN || 'nex';
|
|
50
49
|
|
|
51
50
|
const isTTY = process.stderr.isTTY === true;
|
|
@@ -53,10 +52,13 @@ const c = isTTY
|
|
|
53
52
|
? { dim: '\x1b[2m', green: '\x1b[32m', yellow: '\x1b[33m', red: '\x1b[31m', reset: '\x1b[0m' }
|
|
54
53
|
: { dim: '', green: '', yellow: '', red: '', reset: '' };
|
|
55
54
|
|
|
56
|
-
const info
|
|
57
|
-
const warn
|
|
58
|
-
const ok
|
|
59
|
-
const fatal = (msg) => {
|
|
55
|
+
const info = (msg) => process.stderr.write(`${c.dim}[nex-watch]${c.reset} ${msg}\n`);
|
|
56
|
+
const warn = (msg) => process.stderr.write(`${c.yellow}[nex-watch]${c.reset} ${msg}\n`);
|
|
57
|
+
const ok = (msg) => process.stderr.write(`${c.green}[nex-watch]${c.reset} ${msg}\n`);
|
|
58
|
+
const fatal = (msg) => {
|
|
59
|
+
process.stderr.write(`${c.red}[nex-watch]${c.reset} ${msg}\n`);
|
|
60
|
+
process.exit(1);
|
|
61
|
+
};
|
|
60
62
|
|
|
61
63
|
// Kill-type signals worth auto-relaunching on. SIGKILL is the un-catchable
|
|
62
64
|
// OOM/Jetsam case this tool exists for; SIGTERM is included because some
|
|
@@ -89,17 +91,20 @@ for (;;) {
|
|
|
89
91
|
if (attempt > MAX_RETRIES) {
|
|
90
92
|
fatal(
|
|
91
93
|
`nex was killed (${result.signal}) ${MAX_RETRIES} times in a row — giving up. ` +
|
|
92
|
-
|
|
93
|
-
|
|
94
|
+
`This usually means the machine is critically low on memory; close other applications ` +
|
|
95
|
+
`before retrying. Progress is saved — run 'nex --resume last' manually once memory is free.`,
|
|
94
96
|
);
|
|
95
97
|
}
|
|
96
98
|
warn(
|
|
97
99
|
`nex was killed (${result.signal}) — this is the OS's low-memory killer, not a nex bug. ` +
|
|
98
|
-
|
|
100
|
+
`Progress up to the last saved turn is safe. Retrying (${attempt}/${MAX_RETRIES}) in 2s...`,
|
|
99
101
|
);
|
|
100
102
|
// Synchronous sleep via spawnSync on a no-op — avoids pulling in an async
|
|
101
103
|
// main() just for one delay, keeping this script a simple top-level loop.
|
|
102
|
-
spawnSync(process.platform === 'win32' ? 'timeout' : 'sleep', [process.platform === 'win32' ? '/t 2' : '2'], {
|
|
104
|
+
spawnSync(process.platform === 'win32' ? 'timeout' : 'sleep', [process.platform === 'win32' ? '/t 2' : '2'], {
|
|
105
|
+
stdio: 'ignore',
|
|
106
|
+
shell: process.platform === 'win32',
|
|
107
|
+
});
|
|
103
108
|
continue;
|
|
104
109
|
}
|
|
105
110
|
|