replicas-cli 0.3.235 → 0.3.236
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.cjs +19 -3
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -15840,6 +15840,9 @@ var init_zod = __esm({
|
|
|
15840
15840
|
function isWorkspaceSize(value) {
|
|
15841
15841
|
return WORKSPACE_SIZES.some((size) => size === value);
|
|
15842
15842
|
}
|
|
15843
|
+
function trimLogTailCommand(file2, maxBytes, keepBytes) {
|
|
15844
|
+
return `size=$(stat -c %s ${file2} 2>/dev/null || echo 0); [ "$size" -gt ${maxBytes} ] && { fallocate --collapse-range --offset 0 --length $(( (size - ${keepBytes}) / 4096 * 4096 )) ${file2} 2>/dev/null || truncate -s 0 ${file2}; }`;
|
|
15845
|
+
}
|
|
15843
15846
|
var SANDBOX_LIFECYCLE, SANDBOX_PATHS, WORKSPACE_SIZES, DEFAULT_WORKSPACE_SIZE, INVALID_WORKSPACE_SIZE_ERROR;
|
|
15844
15847
|
var init_sandbox = __esm({
|
|
15845
15848
|
"../shared/src/sandbox.ts"() {
|
|
@@ -31423,7 +31426,7 @@ var CLI_VERSION;
|
|
|
31423
31426
|
var init_cli_version = __esm({
|
|
31424
31427
|
"../shared/src/cli-version.ts"() {
|
|
31425
31428
|
"use strict";
|
|
31426
|
-
CLI_VERSION = "0.3.
|
|
31429
|
+
CLI_VERSION = "0.3.236";
|
|
31427
31430
|
}
|
|
31428
31431
|
});
|
|
31429
31432
|
|
|
@@ -39064,10 +39067,17 @@ async function killServiceGroup(pid) {
|
|
|
39064
39067
|
}
|
|
39065
39068
|
}
|
|
39066
39069
|
function tailLog(logFile, lines) {
|
|
39070
|
+
let fd;
|
|
39067
39071
|
try {
|
|
39068
|
-
|
|
39072
|
+
fd = (0, import_node_fs5.openSync)(logFile, "r");
|
|
39073
|
+
const { size } = (0, import_node_fs5.fstatSync)(fd);
|
|
39074
|
+
const buffer = Buffer.alloc(Math.min(size, LOG_KEEP_BYTES));
|
|
39075
|
+
const read = (0, import_node_fs5.readSync)(fd, buffer, 0, buffer.length, size - buffer.length);
|
|
39076
|
+
return tailLines(buffer.toString("utf-8", 0, read), lines);
|
|
39069
39077
|
} catch {
|
|
39070
39078
|
return "";
|
|
39079
|
+
} finally {
|
|
39080
|
+
if (fd !== void 0) (0, import_node_fs5.closeSync)(fd);
|
|
39071
39081
|
}
|
|
39072
39082
|
}
|
|
39073
39083
|
async function serviceStartCommand(name, commandParts, options) {
|
|
@@ -39101,6 +39111,7 @@ async function serviceStartCommand(name, commandParts, options) {
|
|
|
39101
39111
|
throw new Error("Failed to spawn service process");
|
|
39102
39112
|
}
|
|
39103
39113
|
child.unref();
|
|
39114
|
+
(0, import_node_child_process3.spawn)("bash", ["-c", LOG_TRIM_LOOP, "replicas-service-log-trim", logFile, String(child.pid)], { detached: true, stdio: "ignore" }).unref();
|
|
39104
39115
|
const state = {
|
|
39105
39116
|
name,
|
|
39106
39117
|
command,
|
|
@@ -39170,7 +39181,7 @@ async function serviceLogsCommand(name, options) {
|
|
|
39170
39181
|
console.log(logs || "(no log output yet)");
|
|
39171
39182
|
});
|
|
39172
39183
|
}
|
|
39173
|
-
var import_chalk31, import_node_child_process3, import_node_fs5, import_node_os3, import_node_path4, SERVICES_DIR, NAME_PATTERN;
|
|
39184
|
+
var import_chalk31, import_node_child_process3, import_node_fs5, import_node_os3, import_node_path4, SERVICES_DIR, NAME_PATTERN, LOG_KEEP_BYTES, LOG_TRIM_LOOP;
|
|
39174
39185
|
var init_service = __esm({
|
|
39175
39186
|
"src/commands/service.ts"() {
|
|
39176
39187
|
"use strict";
|
|
@@ -39179,9 +39190,14 @@ var init_service = __esm({
|
|
|
39179
39190
|
import_node_fs5 = require("fs");
|
|
39180
39191
|
import_node_os3 = require("os");
|
|
39181
39192
|
import_node_path4 = require("path");
|
|
39193
|
+
init_src();
|
|
39182
39194
|
init_output();
|
|
39183
39195
|
SERVICES_DIR = (0, import_node_path4.join)((0, import_node_os3.homedir)(), ".replicas", "services");
|
|
39184
39196
|
NAME_PATTERN = /^[a-zA-Z0-9][a-zA-Z0-9._-]*$/;
|
|
39197
|
+
LOG_KEEP_BYTES = 5 * 1024 * 1024;
|
|
39198
|
+
LOG_TRIM_LOOP = `trim() { ${trimLogTailCommand('"$1"', 10 * 1024 * 1024, LOG_KEEP_BYTES)}; }
|
|
39199
|
+
while kill -0 -"$2" 2>/dev/null; do trim "$1"; sleep 1; done
|
|
39200
|
+
trim "$1"`;
|
|
39185
39201
|
}
|
|
39186
39202
|
});
|
|
39187
39203
|
|