Self-hosted, Self-Improving, Federated Everything App — dev management, agent orchestration, persistent mind, digital twin, second brain, and creative pipeline from a single dashboard over Tailscale to port the user into the OS
JavaScript ai-agentsdashboarddeveloper-toolsdigital-twinquantified-selfsecond-brainself-hostedtailscale
fix: self-update SIGPIPE death when PM2 watch restarts server mid-update
Adam Eivy5a490b882fb7
diff --git a/.changelog/NEXT.md b/.changelog/NEXT.mdnew file mode 100644index 0000000000..76f972f4ff--- /dev/null+++ b/.changelog/NEXT.md@@ -0,0 +1,4 @@+### Fixed++- Self-update failing with "exit code null" at npm-install step — PM2 watch restarted the server during `git checkout` (which changes `server/` files), breaking the stdout pipe to the update script. SIGPIPE killed the script before `|| true` could handle it, leaving the update incomplete. Added `trap '' PIPE` to ignore SIGPIPE so the script runs to completion.+- Improved update error messages to show signal name (e.g., "killed by SIGPIPE") instead of opaque "exit code null"diff --git a/scripts/portos-update.sh b/scripts/portos-update.shindex b6d5141563..52f76c519f 100755--- a/scripts/portos-update.sh+++ b/scripts/portos-update.sh@@ -1,6 +1,12 @@#!/usr/bin/env bashset -euo pipefail+# Ignore SIGPIPE: when PM2 restarts the server mid-update (watch detects+# git-checkout file changes), the parent Node process dies and our stdout+# pipe breaks. Without this trap, SIGPIPE kills the script before+# `|| true` can fire, leaving the update incomplete.+trap '' PIPE+# PortOS Auto-Update Script# Usage: bash scripts/portos-update.sh <tag># Outputs structured STEP markers for progress tracking:diff --git a/server/services/updateExecutor.js b/server/services/updateExecutor.jsindex 1630dbb914..c2bd50ff15 100644--- a/server/services/updateExecutor.js+++ b/server/services/updateExecutor.js@@ -63,22 +63,23 @@ export async function executeUpdate(tag, emit) {child.stderr.on('data', makeLineHandler());}- child.on('close', async (code) => {+ child.on('close', async (code, signal) => {const success = code === 0;+ const exitDetail = signal ? `killed by ${signal}` : `exit code ${code}`;await recordUpdateResult({version: tag.replace(/^v/, ''),success,completedAt: new Date().toISOString(),- log: success ? '' : `Process exited with code ${code}`+ log: success ? '' : `Process ${exitDetail}`}).catch(e => console.error(`❌ Failed to record update result: ${e.message}`));if (success) {emit('complete', 'done', `Update to ${tag} complete`);} else {- emit(lastStep, 'error', `Update failed at step "${lastStep}" (exit code ${code})`);+ emit(lastStep, 'error', `Update failed at step "${lastStep}" (${exitDetail})`);}resolve(success? { success: true }- : { success: false, failedStep: lastStep, errorMessage: `Update failed at step "${lastStep}" (exit code ${code})` }+ : { success: false, failedStep: lastStep, errorMessage: `Update failed at step "${lastStep}" (${exitDetail})` });});