lianrouter 2.3.0 → 2.3.1

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.
Files changed (2) hide show
  1. package/dist/cli.js +32 -3
  2. package/package.json +1 -1
package/dist/cli.js CHANGED
@@ -17,7 +17,7 @@ var package_default;
17
17
  var init_package = __esm(() => {
18
18
  package_default = {
19
19
  name: "lianrouter",
20
- version: "2.3.0",
20
+ version: "2.3.1",
21
21
  description: "LianRouter launcher: install, run and control the gateway from one command",
22
22
  type: "module",
23
23
  bin: {
@@ -3070,6 +3070,16 @@ async function readTrayPid(installRoot) {
3070
3070
  return Number.isInteger(pid) && pid > 0 ? pid : undefined;
3071
3071
  }
3072
3072
 
3073
+ // cli/tray/connection.ts
3074
+ function isProcessAlive2(pid) {
3075
+ try {
3076
+ process.kill(pid, 0);
3077
+ return true;
3078
+ } catch {
3079
+ return false;
3080
+ }
3081
+ }
3082
+
3073
3083
  // cli/src/launcher.ts
3074
3084
  var USAGE = `lianrouter v${CLI_VERSION}
3075
3085
 
@@ -3512,11 +3522,30 @@ async function runUpdateWithProgress(supervisor, session, runtime) {
3512
3522
  async function startTrayHost(supervisor, session, runtime) {
3513
3523
  await ensureStarted(supervisor);
3514
3524
  const result = await startTray(runtime.devRepoRoot === undefined ? { installRoot: runtime.installRoot, control: session.handshake } : { installRoot: runtime.installRoot, control: session.handshake, devRepoRoot: runtime.devRepoRoot });
3515
- if (result.ok) {
3516
- hideConsoleWindow();
3525
+ if (!result.ok) {
3526
+ return result;
3517
3527
  }
3528
+ if (!await traySurvivedStartup(result.pid)) {
3529
+ return {
3530
+ ok: false,
3531
+ error: "The tray host exited while starting, so the console was left visible. Run `lianrouter tray` from a terminal to see why."
3532
+ };
3533
+ }
3534
+ hideConsoleWindow();
3518
3535
  return result;
3519
3536
  }
3537
+ var TRAY_STARTUP_GRACE_MS = 3000;
3538
+ var TRAY_STARTUP_POLL_MS = 150;
3539
+ async function traySurvivedStartup(pid, graceMs = TRAY_STARTUP_GRACE_MS) {
3540
+ const deadline = Date.now() + graceMs;
3541
+ while (Date.now() < deadline) {
3542
+ if (!isProcessAlive2(pid)) {
3543
+ return false;
3544
+ }
3545
+ await Bun.sleep(TRAY_STARTUP_POLL_MS);
3546
+ }
3547
+ return isProcessAlive2(pid);
3548
+ }
3520
3549
  async function blockUntilTrayExit(supervisor, session, runtime) {
3521
3550
  await new Promise((resolve) => {
3522
3551
  let settled = false;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lianrouter",
3
- "version": "2.3.0",
3
+ "version": "2.3.1",
4
4
  "description": "LianRouter launcher: install, run and control the gateway from one command",
5
5
  "type": "module",
6
6
  "bin": {