From dbcb378636993ca250fe61f2734ba99700493fd4 Mon Sep 17 00:00:00 2001 From: sjcoetzeesj-coder Date: Tue, 27 Oct 2026 12:20:16 +0200 Subject: [PATCH] chore(dev): keep the detached dev-server start script Running "npm run dev" as a tracked agent task gets the process killed when the runtime cap is reached, which leaves the machine with no dev server on port 6001. This script starts it with Start-Process so it survives session churn, and it refuses to start a second server when the port is already taken. The older .run-dev.ps1 in the same folder is broken and is replaced by this one: it invokes the Next binary without its extension, which PowerShell cannot execute, so node.exe is called explicitly instead. --- Workflow/.start-dev-detached.ps1 | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 Workflow/.start-dev-detached.ps1 diff --git a/Workflow/.start-dev-detached.ps1 b/Workflow/.start-dev-detached.ps1 new file mode 100644 index 0000000..66059d5 --- /dev/null +++ b/Workflow/.start-dev-detached.ps1 @@ -0,0 +1,30 @@ +# Start the Workflow dev server fully detached from the agent session. +# +# WHY THIS FILE EXISTS +# Running "npm run dev" as a tracked background task gets the process +# killed when the runtime 3600000ms cap is reached (about 1 hour). +# Start-Process detaches it, so it survives session churn. +# +# NOTE: the older .run-dev.ps1 in this folder is broken. It calls +# & '.\node_modules\next\dist\bin\next' +# but that path has no extension, so PowerShell cannot execute it. +# node.exe must be invoked explicitly, which is what this script does. +# +# Usage: powershell -NoProfile -ExecutionPolicy Bypass -File .start-dev-detached.ps1 + +$ErrorActionPreference = 'Continue' + +$root = 'C:\Users\SJ\.minimax-agent\projects\Workflow' +$logFile = Join-Path $root '.dev-detached.log' + +# Do not start a second server if one is already listening on 6001. +$existing = (Get-NetTCPConnection -LocalPort 6001 -State Listen -ErrorAction SilentlyContinue).OwningProcess +if ($existing) { + Write-Host "Port 6001 already in use by PID $existing. Nothing to do." + exit 0 +} + +$proc = Start-Process -FilePath 'node.exe' -ArgumentList 'node_modules\next\dist\bin\next','dev','-p','6001' -WorkingDirectory $root -WindowStyle Hidden -RedirectStandardOutput $logFile -RedirectStandardError "$logFile.err" -PassThru + +Write-Host "Workflow dev server started detached (PID $($proc.Id))." +Write-Host "Log: $logFile" \ No newline at end of file