@openai-lite/codex-feishu 0.1.1 → 0.1.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/package.json +1 -1
- package/src/lib/daemon_control.js +13 -5
package/package.json
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import fs from "node:fs";
|
|
2
2
|
import { spawn, spawnSync } from "node:child_process";
|
|
3
|
+
import { fileURLToPath } from "node:url";
|
|
3
4
|
import { ensureDir, readTextIfExists, writeText } from "./fs_utils.js";
|
|
4
5
|
import { getDaemonLogPath, getDaemonPidPath, getRunDir } from "./paths.js";
|
|
5
6
|
|
|
@@ -182,27 +183,34 @@ export async function restartDaemonDetached() {
|
|
|
182
183
|
await removePidFile();
|
|
183
184
|
|
|
184
185
|
const entry = process.argv[1];
|
|
186
|
+
const stableCliEntry = fileURLToPath(new URL("../cli.js", import.meta.url));
|
|
187
|
+
const candidateEntries = [...new Set([stableCliEntry, entry].filter(Boolean))];
|
|
185
188
|
const attempts = [];
|
|
186
|
-
if (process.platform === "win32"
|
|
187
|
-
|
|
189
|
+
if (process.platform === "win32") {
|
|
190
|
+
for (const cliEntry of candidateEntries) {
|
|
191
|
+
attempts.push([process.execPath, [cliEntry, "daemon"]]);
|
|
192
|
+
}
|
|
188
193
|
attempts.push(["codex-feishu", ["daemon"]]);
|
|
189
194
|
} else {
|
|
190
195
|
attempts.push(["codex-feishu", ["daemon"]]);
|
|
191
|
-
|
|
192
|
-
attempts.push([process.execPath, [
|
|
196
|
+
for (const cliEntry of candidateEntries) {
|
|
197
|
+
attempts.push([process.execPath, [cliEntry, "daemon"]]);
|
|
193
198
|
}
|
|
194
199
|
}
|
|
195
200
|
|
|
196
201
|
let startResult = { ok: false, error: "no_start_attempt" };
|
|
202
|
+
const failedAttempts = [];
|
|
197
203
|
for (const [cmd, args] of attempts) {
|
|
198
204
|
// eslint-disable-next-line no-await-in-loop
|
|
199
205
|
startResult = await trySpawnDetached(cmd, args, logPath);
|
|
200
206
|
if (startResult.ok) {
|
|
201
207
|
break;
|
|
202
208
|
}
|
|
209
|
+
failedAttempts.push(`${cmd} ${args.join(" ")} => ${startResult.error}`);
|
|
203
210
|
}
|
|
204
211
|
if (!startResult.ok) {
|
|
205
|
-
|
|
212
|
+
const details = failedAttempts.length > 0 ? `; attempts: ${failedAttempts.join(" | ")}` : "";
|
|
213
|
+
throw new Error(`failed to start daemon in background: ${startResult.error}${details}`);
|
|
206
214
|
}
|
|
207
215
|
|
|
208
216
|
await writeText(pidPath, `${startResult.pid}\n`);
|