c8ctl-plugin-nano 1.33.1 → 1.33.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/c8ctl-plugin.js +39 -6
- package/package.json +8 -8
package/c8ctl-plugin.js
CHANGED
|
@@ -161,6 +161,17 @@ function getLogger() {
|
|
|
161
161
|
warn: console.warn,
|
|
162
162
|
error: console.error,
|
|
163
163
|
debug: () => {},
|
|
164
|
+
// Primary command output, written to stdout as-is (mirrors the c8ctl host
|
|
165
|
+
// logger's `output()`). Used for preformatted, non-structured content such
|
|
166
|
+
// as the supervisor status table, whose newlines must survive verbatim.
|
|
167
|
+
// Uses `process.stdout.write` (not `console.log`) so the content is emitted
|
|
168
|
+
// literally — `console.log` applies `util.format` (mangling stray `%`
|
|
169
|
+
// sequences) and would append its own newline; here we add exactly one
|
|
170
|
+
// trailing newline when the text lacks one.
|
|
171
|
+
output: (msg) => {
|
|
172
|
+
const s = typeof msg === 'string' ? msg : String(msg);
|
|
173
|
+
process.stdout.write(s.endsWith('\n') ? s : s + '\n');
|
|
174
|
+
},
|
|
164
175
|
};
|
|
165
176
|
}
|
|
166
177
|
|
|
@@ -1244,7 +1255,7 @@ function logsCluster(req) {
|
|
|
1244
1255
|
const proc = spawn('tail', tailArgs, { stdio: ['ignore', 'inherit', 'inherit'] });
|
|
1245
1256
|
proc.on('error', (err) => {
|
|
1246
1257
|
logger.error(`Failed to read logs: ${err.message}`);
|
|
1247
|
-
logger.
|
|
1258
|
+
logger.output(`Log files:\n ${files.join('\n ')}`);
|
|
1248
1259
|
});
|
|
1249
1260
|
}
|
|
1250
1261
|
|
|
@@ -5094,6 +5105,27 @@ function formatSupervisorStatus(status) {
|
|
|
5094
5105
|
return lines.join('\n');
|
|
5095
5106
|
}
|
|
5096
5107
|
|
|
5108
|
+
/**
|
|
5109
|
+
* Print a preformatted supervisor status table as primary command output.
|
|
5110
|
+
*
|
|
5111
|
+
* Preformatted, multi-line text MUST go through the logger's `output()`
|
|
5112
|
+
* channel, never `info()`. In `--output json` mode the c8ctl host logger wraps
|
|
5113
|
+
* an `info()` message in a JSON envelope (`{"status":"info","message":"…"}`),
|
|
5114
|
+
* which escapes every newline to a literal `\n` and collapses the aligned table
|
|
5115
|
+
* onto a single line — the exact breakage this guards against. `output()` writes
|
|
5116
|
+
* the content to stdout verbatim in every output mode (like `raw` command
|
|
5117
|
+
* output), so the table renders correctly regardless of mode. Falls back to
|
|
5118
|
+
* `info()` for a logger without `output()`, and to `console.log` if `logger`
|
|
5119
|
+
* is null/undefined or lacks `info()` (defensive; both the c8ctl host logger
|
|
5120
|
+
* and this plugin's fallback logger provide `output()`).
|
|
5121
|
+
*/
|
|
5122
|
+
function printSupervisorStatus(logger, status) {
|
|
5123
|
+
const text = formatSupervisorStatus(status);
|
|
5124
|
+
if (logger && typeof logger.output === 'function') logger.output(text);
|
|
5125
|
+
else if (logger && typeof logger.info === 'function') logger.info(text);
|
|
5126
|
+
else console.log(text);
|
|
5127
|
+
}
|
|
5128
|
+
|
|
5097
5129
|
function readSupervisorState() {
|
|
5098
5130
|
const file = getSupervisorStateFile();
|
|
5099
5131
|
if (!existsSync(file)) return null;
|
|
@@ -5727,7 +5759,7 @@ async function supervisorStatusCmd() {
|
|
|
5727
5759
|
const res = await supervisorRequest({ op: 'status' }, { socketPath: getSupervisorSocketPath(), timeoutMs: 500, responseTimeoutMs: SUPERVISOR_PROBE_RESPONSE_TIMEOUT_MS });
|
|
5728
5760
|
if (res && res.ok) {
|
|
5729
5761
|
try { writeSupervisorState(stateFromStatus(res, getSupervisorSocketPath())); } catch { /* best effort */ }
|
|
5730
|
-
logger
|
|
5762
|
+
printSupervisorStatus(logger, res);
|
|
5731
5763
|
return;
|
|
5732
5764
|
}
|
|
5733
5765
|
} catch { /* no live daemon on the socket — genuinely down */ }
|
|
@@ -5743,13 +5775,13 @@ async function supervisorStatusCmd() {
|
|
|
5743
5775
|
}
|
|
5744
5776
|
try {
|
|
5745
5777
|
const res = await supervisorRequest({ op: 'status' });
|
|
5746
|
-
if (res.ok) { logger
|
|
5778
|
+
if (res.ok) { printSupervisorStatus(logger, res); return; }
|
|
5747
5779
|
} catch { /* fall back to state file below */ }
|
|
5748
5780
|
// Socket unreachable but pid alive — render from the last persisted state.
|
|
5749
|
-
logger
|
|
5781
|
+
printSupervisorStatus(logger, {
|
|
5750
5782
|
daemon: { pid: running.pid, startedAt: running.startedAt, socket: running.socket },
|
|
5751
5783
|
workers: (running.workers || []).map((w) => summarizeSupervisorWorker(w)),
|
|
5752
|
-
})
|
|
5784
|
+
});
|
|
5753
5785
|
}
|
|
5754
5786
|
|
|
5755
5787
|
async function supervisorAddCmd(req, flags) {
|
|
@@ -5862,7 +5894,7 @@ function supervisorLogsCmd(req) {
|
|
|
5862
5894
|
if (follow) logger.warn('`--follow` is not supported without `tail` on this platform; printing the current tail only.');
|
|
5863
5895
|
try {
|
|
5864
5896
|
const lines = readFileSync(file, 'utf-8').split('\n');
|
|
5865
|
-
logger.
|
|
5897
|
+
logger.output(lines.slice(-200).join('\n'));
|
|
5866
5898
|
} catch (err) { logger.error(`Could not read ${file}: ${err.message}`); }
|
|
5867
5899
|
});
|
|
5868
5900
|
}
|
|
@@ -7624,6 +7656,7 @@ export {
|
|
|
7624
7656
|
formatDuration,
|
|
7625
7657
|
summarizeSupervisorWorker,
|
|
7626
7658
|
formatSupervisorStatus,
|
|
7659
|
+
printSupervisorStatus,
|
|
7627
7660
|
supervisorStatusSignature,
|
|
7628
7661
|
supervisorJobCell,
|
|
7629
7662
|
supervisorWorkerActivityFile,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "c8ctl-plugin-nano",
|
|
3
|
-
"version": "1.33.
|
|
3
|
+
"version": "1.33.2",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "c8ctl plugin to start, inspect, and stop a local Nano BPM (nanobpmn) cluster",
|
|
6
6
|
"main": "c8ctl-plugin.js",
|
|
@@ -57,12 +57,12 @@
|
|
|
57
57
|
},
|
|
58
58
|
"optionalDependencies": {
|
|
59
59
|
"node-pty": "^1.0.0",
|
|
60
|
-
"@nanobpm/c8ctl-plugin-nano-darwin-arm64": "1.33.
|
|
61
|
-
"@nanobpm/c8ctl-plugin-nano-darwin-x64": "1.33.
|
|
62
|
-
"@nanobpm/c8ctl-plugin-nano-linux-x64": "1.33.
|
|
63
|
-
"@nanobpm/c8ctl-plugin-nano-linux-arm64": "1.33.
|
|
64
|
-
"@nanobpm/c8ctl-plugin-nano-linux-armv7": "1.33.
|
|
65
|
-
"@nanobpm/c8ctl-plugin-nano-linux-armv6": "1.33.
|
|
66
|
-
"@nanobpm/c8ctl-plugin-nano-win32-x64": "1.33.
|
|
60
|
+
"@nanobpm/c8ctl-plugin-nano-darwin-arm64": "1.33.2",
|
|
61
|
+
"@nanobpm/c8ctl-plugin-nano-darwin-x64": "1.33.2",
|
|
62
|
+
"@nanobpm/c8ctl-plugin-nano-linux-x64": "1.33.2",
|
|
63
|
+
"@nanobpm/c8ctl-plugin-nano-linux-arm64": "1.33.2",
|
|
64
|
+
"@nanobpm/c8ctl-plugin-nano-linux-armv7": "1.33.2",
|
|
65
|
+
"@nanobpm/c8ctl-plugin-nano-linux-armv6": "1.33.2",
|
|
66
|
+
"@nanobpm/c8ctl-plugin-nano-win32-x64": "1.33.2"
|
|
67
67
|
}
|
|
68
68
|
}
|