@bivy/bivy 0.15.0-staging.2 → 0.15.0-staging.4
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/bin/bivy.mjs +46 -7
- package/package.json +1 -1
package/bin/bivy.mjs
CHANGED
|
@@ -4234,6 +4234,51 @@ async function tailFiles(files, lines, follow) {
|
|
|
4234
4234
|
// alive. Keeping stdout pointed directly at the log lets the update survive the
|
|
4235
4235
|
// node restart; polling it here still gives the web terminal live progress up to
|
|
4236
4236
|
// the moment its PTY disappears.
|
|
4237
|
+
function spawnDetachedUpdateProcess(args, logFd) {
|
|
4238
|
+
const env = { ...process.env, BIVY_UPDATE_DETACHED: "1" };
|
|
4239
|
+
const updateArgs = [selfScript, "update", ...args];
|
|
4240
|
+
const { kind } = servicePaths();
|
|
4241
|
+
|
|
4242
|
+
// A Bivy web terminal is a child of bivy.service. A plain detached child still
|
|
4243
|
+
// stays in that systemd cgroup, so the installer's early `bivy stop` would kill
|
|
4244
|
+
// the updater along with the node before npm/install runs. When a user systemd
|
|
4245
|
+
// manager is available, launch the updater as its own transient unit instead;
|
|
4246
|
+
// stopping/restarting bivy.service then leaves the updater alive.
|
|
4247
|
+
if (kind === "systemd" && commandExists("systemd-run")) {
|
|
4248
|
+
const unit = `bivy-update-${process.pid}-${Date.now()}`.replace(/[^A-Za-z0-9_.@-]/g, "-");
|
|
4249
|
+
const logProp = `append:${updateLogPath}`;
|
|
4250
|
+
const child = spawn("systemd-run", [
|
|
4251
|
+
"--user",
|
|
4252
|
+
"--wait",
|
|
4253
|
+
"--collect",
|
|
4254
|
+
`--unit=${unit}`,
|
|
4255
|
+
`--working-directory=${repoRoot}`,
|
|
4256
|
+
`--property=StandardOutput=${logProp}`,
|
|
4257
|
+
`--property=StandardError=${logProp}`,
|
|
4258
|
+
"--setenv=BIVY_UPDATE_DETACHED=1",
|
|
4259
|
+
`--setenv=BIVY_DATA_DIR=${appDir}`,
|
|
4260
|
+
`--setenv=PATH=${process.env.PATH || ""}`,
|
|
4261
|
+
nodeBin,
|
|
4262
|
+
...updateArgs,
|
|
4263
|
+
], {
|
|
4264
|
+
detached: true,
|
|
4265
|
+
stdio: ["ignore", logFd, logFd],
|
|
4266
|
+
env: { ...env, ...systemdUserEnv() },
|
|
4267
|
+
});
|
|
4268
|
+
child.unref();
|
|
4269
|
+
return child;
|
|
4270
|
+
}
|
|
4271
|
+
|
|
4272
|
+
const child = spawn(nodeBin, updateArgs, {
|
|
4273
|
+
cwd: repoRoot,
|
|
4274
|
+
detached: true,
|
|
4275
|
+
stdio: ["ignore", logFd, logFd],
|
|
4276
|
+
env,
|
|
4277
|
+
});
|
|
4278
|
+
child.unref();
|
|
4279
|
+
return child;
|
|
4280
|
+
}
|
|
4281
|
+
|
|
4237
4282
|
async function showDetachedUpdateProgress(child, start) {
|
|
4238
4283
|
let offset = start;
|
|
4239
4284
|
let finished = false;
|
|
@@ -4289,13 +4334,7 @@ async function cmdUpdate(args = []) {
|
|
|
4289
4334
|
const logFd = fs.openSync(updateLogPath, "a");
|
|
4290
4335
|
const logStart = fs.fstatSync(logFd).size;
|
|
4291
4336
|
fs.writeSync(logFd, `\n=== bivy update started ${new Date().toISOString()} ===\n`);
|
|
4292
|
-
const child =
|
|
4293
|
-
cwd: repoRoot,
|
|
4294
|
-
detached: true,
|
|
4295
|
-
stdio: ["ignore", logFd, logFd],
|
|
4296
|
-
env: { ...process.env, BIVY_UPDATE_DETACHED: "1" },
|
|
4297
|
-
});
|
|
4298
|
-
child.unref();
|
|
4337
|
+
const child = spawnDetachedUpdateProcess(args, logFd);
|
|
4299
4338
|
fs.closeSync(logFd);
|
|
4300
4339
|
console.log(c.green("Update started in the background. Showing progress until the node restarts…"));
|
|
4301
4340
|
console.log(c.dim(`The terminal will reconnect automatically. Run ${c.cyan("bivy update:log")} afterward for the final output.`));
|
package/package.json
CHANGED