cartethyia 2.4.1 → 2.4.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/dist/dashboard/assets/{BannedPage-hGt6sYfC.js → BannedPage-KprmzKo8.js} +1 -1
- package/dist/dashboard/assets/{CliToolDetailPage-C-v5GoF-.js → CliToolDetailPage-BL_oNmmg.js} +1 -1
- package/dist/dashboard/assets/{CliToolsPage-Da2XCM9A.js → CliToolsPage-XjDkuNCh.js} +1 -1
- package/dist/dashboard/assets/{ConsoleLogPage-xT-LP8xZ.js → ConsoleLogPage-COtZ6SqU.js} +1 -1
- package/dist/dashboard/assets/{CustomizationPage-D0PQsW3f.js → CustomizationPage-0K0ySe8K.js} +1 -1
- package/dist/dashboard/assets/{HealthEventsModal-DTiQ4ulO.js → HealthEventsModal-O05igcJY.js} +1 -1
- package/dist/dashboard/assets/{LoginPage-jMx71m_m.js → LoginPage-a_voqncN.js} +1 -1
- package/dist/dashboard/assets/{OverviewPage-BQpanEmj.js → OverviewPage-hl2ua1qC.js} +1 -1
- package/dist/dashboard/assets/{ProviderDetailPage-DMh9bfu0.js → ProviderDetailPage-CjpQIFMI.js} +1 -1
- package/dist/dashboard/assets/{ProvidersPage-Bfg0qSLE.js → ProvidersPage-xsrxYHsk.js} +1 -1
- package/dist/dashboard/assets/{ProxyPage-CSSN-6vg.js → ProxyPage-Bm8Eu21x.js} +1 -1
- package/dist/dashboard/assets/{QuotaPage-BPksahOs.js → QuotaPage-BKU9VtlD.js} +1 -1
- package/dist/dashboard/assets/{SetupPage-DxKaH8LS.js → SetupPage-CdjhQfnC.js} +1 -1
- package/dist/dashboard/assets/{StudioPage-B9WEa99R.js → StudioPage-DMGEaI3G.js} +1 -1
- package/dist/dashboard/assets/{UsagePage-BOSJhVq0.js → UsagePage-B6D-eJDG.js} +1 -1
- package/dist/dashboard/assets/{entry-C1Dn2nQu.js → entry-B92UGcyr.js} +3 -3
- package/dist/dashboard/assets/{index-TZNbg9dv.js → index-BGSJSZeV.js} +2 -2
- package/dist/dashboard/index.html +1 -1
- package/package.json +1 -1
- package/scripts/cli/cli.ts +15 -35
package/scripts/cli/cli.ts
CHANGED
|
@@ -437,18 +437,13 @@ async function startMenu(): Promise<void> {
|
|
|
437
437
|
latestVersion = await readLatestPublishedVersion();
|
|
438
438
|
},
|
|
439
439
|
async () => {
|
|
440
|
-
//
|
|
441
|
-
//
|
|
442
|
-
//
|
|
443
|
-
//
|
|
444
|
-
//
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
handedOff = true;
|
|
448
|
-
console.log("Handing the gateway to the tray…");
|
|
449
|
-
await shutDown();
|
|
450
|
-
const replacement = await startGateway(port, drainToken, { detached: true });
|
|
451
|
-
replacement.unref();
|
|
440
|
+
// Start a detached `tray` process that owns the gateway from scratch,
|
|
441
|
+
// then drain this one so the new process can claim the port. This is
|
|
442
|
+
// the pattern 9router uses and it is simpler than handing a live
|
|
443
|
+
// gateway between processes: the tray is a normal first-class run, not
|
|
444
|
+
// an adopted orphan, so Exit and update behave the same whether the
|
|
445
|
+
// gateway was started here or from `carte --tray`.
|
|
446
|
+
console.log("Starting the tray in the background…");
|
|
452
447
|
const tray = spawn(
|
|
453
448
|
process.execPath,
|
|
454
449
|
["run", resolvePackagePath("scripts", "cli", "cli.ts"), "tray"],
|
|
@@ -457,12 +452,16 @@ async function startMenu(): Promise<void> {
|
|
|
457
452
|
detached: true,
|
|
458
453
|
stdio: "ignore",
|
|
459
454
|
windowsHide: true,
|
|
460
|
-
env:
|
|
455
|
+
env: process.env,
|
|
461
456
|
},
|
|
462
457
|
);
|
|
463
458
|
tray.unref();
|
|
464
|
-
|
|
465
|
-
|
|
459
|
+
running = false;
|
|
460
|
+
stopping = true;
|
|
461
|
+
handedOff = true;
|
|
462
|
+
await shutDown();
|
|
463
|
+
console.log(`Cartethyia is running in the background at ${dashboardUrl}.`);
|
|
464
|
+
console.log("The tray icon owns it. Stop it with: cartethyia stop");
|
|
466
465
|
},
|
|
467
466
|
async () => {
|
|
468
467
|
running = false;
|
|
@@ -685,7 +684,6 @@ async function startTray(): Promise<void> {
|
|
|
685
684
|
let closing = false;
|
|
686
685
|
let busy = false;
|
|
687
686
|
let resetArmed = false;
|
|
688
|
-
const adopted = process.env.CARTETHYIA_TRAY_ADOPT_RUNNING === "1";
|
|
689
687
|
let latestVersion: string | null = null;
|
|
690
688
|
let closePromise: Promise<void> | undefined;
|
|
691
689
|
|
|
@@ -695,15 +693,7 @@ async function startTray(): Promise<void> {
|
|
|
695
693
|
closePromise = (async () => {
|
|
696
694
|
const current: ReturnType<typeof Bun.spawn> | null = gateway;
|
|
697
695
|
gateway = null;
|
|
698
|
-
if (current)
|
|
699
|
-
await stopGateway(current, port, drainToken);
|
|
700
|
-
} else if (adopted) {
|
|
701
|
-
// An adopted tray never held the gateway as a child, so there is no
|
|
702
|
-
// process to signal. Draining through the loopback endpoint is the only
|
|
703
|
-
// way Exit stops it — without this, Exit closed the icon and left the
|
|
704
|
-
// gateway listening, which looked like a phantom process.
|
|
705
|
-
await drainThroughEndpoint(port, drainToken);
|
|
706
|
-
}
|
|
696
|
+
if (current) await stopGateway(current, port, drainToken);
|
|
707
697
|
await stopTray(tray, trayReady, trayExited);
|
|
708
698
|
process.exitCode = exitCode;
|
|
709
699
|
})();
|
|
@@ -860,16 +850,6 @@ async function startTray(): Promise<void> {
|
|
|
860
850
|
try {
|
|
861
851
|
await waitForTray(tray);
|
|
862
852
|
trayReady = true;
|
|
863
|
-
// "Hide to tray" hands over a gateway that is already listening. Spawning a
|
|
864
|
-
// second one would fail on the port, so an adopted tray only watches the
|
|
865
|
-
// existing process and stops owning it when the menu process exits.
|
|
866
|
-
if (process.env.CARTETHYIA_TRAY_ADOPT_RUNNING === "1") {
|
|
867
|
-
reportTrayStartup({ status: "ready", url: dashboardUrl });
|
|
868
|
-
console.log(`Cartethyia is running at ${dashboardUrl}`);
|
|
869
|
-
void refreshVersion();
|
|
870
|
-
while (!closing) await Bun.sleep(500);
|
|
871
|
-
return;
|
|
872
|
-
}
|
|
873
853
|
gateway = await startGateway(port, drainToken);
|
|
874
854
|
reportTrayStartup({ status: "ready", url: dashboardUrl });
|
|
875
855
|
console.log(`Cartethyia is running at ${dashboardUrl}`);
|