summaryrefslogtreecommitdiffstats
path: root/packages/meshbay-client/build
diff options
context:
space:
mode:
authorChristophe Besson <cbesson@gmail.com>2026-10-15 17:42:30 +0200
committerChristophe Besson <cbesson@gmail.com>2026-10-15 17:45:41 +0200
commit0d082ab4d19412079516b281aff76e8c3f70d9ba (patch)
tree46bc48f67663c4049384578c594b8558bce2db6c /packages/meshbay-client/build
parent41d03f0a35a95daa7d54e7f29ab924776bedf6e4 (diff)
downloadmeshbay-0d082ab4d19412079516b281aff76e8c3f70d9ba.tar.gz
fix(packaging): setup ends a command-line client run from its install
A `meshbay-cli chat --follow` left open holds node-runtime's DLLs, so the previous version's uninstaller failed ("Failed to uninstall old application files"), a silent update included, and left the node it had stopped not running. stop-node.ps1 now ends a meshbay-cli.exe run from this install (-InstallDir, setup's $INSTDIR), and no other copy. Found through CIM, not Get-Process: setup runs the 32-bit PowerShell, which reads no path for a 64-bit process, and the first version of the stop matched nothing. The test runs the script in that PowerShell. Checked live: an update over a running follower now ends it, replaces every file and restarts the node. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Diffstat (limited to 'packages/meshbay-client/build')
-rw-r--r--packages/meshbay-client/build/installer.nsh6
-rw-r--r--packages/meshbay-client/build/stop-node.ps127
2 files changed, 29 insertions, 4 deletions
diff --git a/packages/meshbay-client/build/installer.nsh b/packages/meshbay-client/build/installer.nsh
index 2337088..ce1e1ea 100644
--- a/packages/meshbay-client/build/installer.nsh
+++ b/packages/meshbay-client/build/installer.nsh
@@ -95,11 +95,11 @@ Var pid
InitPluginsDir
File "/oname=$PLUGINSDIR\mb-stop-node.ps1" "${BUILD_RESOURCES_DIR}\stop-node.ps1"
mb_stop_node:
- DetailPrint "Stopping the MeshBay node..."
- nsExec::Exec `"${MB_PWSH}" -NoProfile -NonInteractive -ExecutionPolicy Bypass -File "$PLUGINSDIR\mb-stop-node.ps1"`
+ DetailPrint "Stopping the MeshBay node and command-line client..."
+ nsExec::Exec `"${MB_PWSH}" -NoProfile -NonInteractive -ExecutionPolicy Bypass -File "$PLUGINSDIR\mb-stop-node.ps1" -InstallDir "$INSTDIR"`
Pop $0
${If} $0 != 0
- MessageBox MB_RETRYCANCEL|MB_ICONEXCLAMATION "The MeshBay node is still running and holds files that setup must replace. Stop it (meshbay-node service stop, or end meshbay-node.exe in Task Manager), then click Retry." /SD IDCANCEL IDRETRY mb_stop_node
+ MessageBox MB_RETRYCANCEL|MB_ICONEXCLAMATION "The MeshBay node or command-line client is still running and holds files that setup must replace. Stop it (meshbay-node service stop, or end meshbay-node.exe and meshbay-cli.exe in Task Manager), then click Retry." /SD IDCANCEL IDRETRY mb_stop_node
Quit
${EndIf}
!insertmacro IS_POWERSHELL_AVAILABLE
diff --git a/packages/meshbay-client/build/stop-node.ps1 b/packages/meshbay-client/build/stop-node.ps1
index cfaf2f8..dcb0ea6 100644
--- a/packages/meshbay-client/build/stop-node.ps1
+++ b/packages/meshbay-client/build/stop-node.ps1
@@ -10,9 +10,34 @@
# 2. Task Scheduler for a background-service node (the owner may end the task;
# taskkill from here gets "Access is denied" in its session).
# 3. taskkill for anything left in this session.
-# Exit 0 once no meshbay-node.exe is left, 1 otherwise.
+#
+# Before all that, the command-line client (-InstallDir, setup's $INSTDIR): it
+# runs from the same node-runtime folder and holds its Python DLLs, so one left
+# open -- a `chat --follow`, a `stream` -- made the previous version's
+# uninstaller fail ("Failed to uninstall old application files"), silent
+# updates included. It is ended like the app is; only copies of this install.
+# Exit 0 once neither is left, 1 otherwise.
+param([string]$InstallDir = "")
$ErrorActionPreference = "SilentlyContinue"
+if ($InstallDir) {
+ $runtime = Join-Path $InstallDir "resources\node-runtime\"
+ # Through CIM, not Get-Process: setup runs the 32-bit PowerShell ($SYSDIR is
+ # SysWOW64 there), which reads no path for a 64-bit process -- the filter
+ # matched nothing and the update failed as before.
+ function CliLeft {
+ @(Get-CimInstance Win32_Process -Filter "Name='meshbay-cli.exe'" `
+ -ErrorAction SilentlyContinue | Where-Object {
+ $_.ExecutablePath -and
+ $_.ExecutablePath.StartsWith($runtime, [StringComparison]::OrdinalIgnoreCase)
+ })
+ }
+ CliLeft | ForEach-Object { Stop-Process -Id $_.ProcessId -Force -ErrorAction SilentlyContinue }
+ $deadline = (Get-Date).AddSeconds(10)
+ while ((CliLeft).Count -and (Get-Date) -lt $deadline) { Start-Sleep -Milliseconds 250 }
+ if ((CliLeft).Count) { exit 1 }
+}
+
function NodeLeft { [bool](Get-Process -Name meshbay-node -ErrorAction SilentlyContinue) }
function WaitGone([int]$Seconds) {
$deadline = (Get-Date).AddSeconds($Seconds)