oasis_test 0.1.17 → 0.1.19
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 +27 -4
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -51122,10 +51122,28 @@ function stopDaemon() {
|
|
|
51122
51122
|
function selfUpdate() {
|
|
51123
51123
|
const cfg = readConfig();
|
|
51124
51124
|
if (!cfg?.serverUrl) throw new Error("no config \u2014 run `oasis start` first");
|
|
51125
|
-
const
|
|
51126
|
-
const
|
|
51127
|
-
const
|
|
51128
|
-
|
|
51125
|
+
const startArgs = ["-y", `${PKG_NAME}@latest`, "start", "--server-ws", cfg.serverUrl, ...cfg.name ? ["--name", cfg.name] : []];
|
|
51126
|
+
const quoted = startArgs.map((a) => `'${a.replace(/'/g, "'\\''")}'`).join(" ");
|
|
51127
|
+
const inner = `sleep 2; npx ${quoted} >> '${LOG_FILE}' 2>&1`;
|
|
51128
|
+
const hasSystemd = process.platform === "linux" && (() => {
|
|
51129
|
+
try {
|
|
51130
|
+
(0, import_node_child_process12.execSync)("command -v systemd-run", { stdio: "ignore" });
|
|
51131
|
+
return true;
|
|
51132
|
+
} catch {
|
|
51133
|
+
return false;
|
|
51134
|
+
}
|
|
51135
|
+
})();
|
|
51136
|
+
if (hasSystemd) {
|
|
51137
|
+
const child = (0, import_node_child_process12.spawn)("systemd-run", ["--user", "--scope", "--quiet", "sh", "-c", inner], {
|
|
51138
|
+
detached: true,
|
|
51139
|
+
stdio: "ignore"
|
|
51140
|
+
});
|
|
51141
|
+
child.unref();
|
|
51142
|
+
} else {
|
|
51143
|
+
const log3 = fs16.openSync(LOG_FILE, "a");
|
|
51144
|
+
const child = (0, import_node_child_process12.spawn)("sh", ["-c", inner], { detached: true, stdio: ["ignore", log3, log3] });
|
|
51145
|
+
child.unref();
|
|
51146
|
+
}
|
|
51129
51147
|
}
|
|
51130
51148
|
void (async () => {
|
|
51131
51149
|
const [, , cmd] = process.argv;
|
|
@@ -51136,6 +51154,11 @@ void (async () => {
|
|
|
51136
51154
|
console.error("[oasis] no config \u2014 run `oasis start` first");
|
|
51137
51155
|
process.exit(1);
|
|
51138
51156
|
}
|
|
51157
|
+
const alivePid = readPid();
|
|
51158
|
+
if (alivePid && alivePid !== process.pid && isRunning(alivePid)) {
|
|
51159
|
+
console.error(`[oasis] daemon already running (PID ${alivePid}) \u2014 exiting duplicate`);
|
|
51160
|
+
process.exit(0);
|
|
51161
|
+
}
|
|
51139
51162
|
fs16.writeFileSync(PID_FILE, String(process.pid));
|
|
51140
51163
|
const cleanup = () => {
|
|
51141
51164
|
try {
|