30 lines
1.4 KiB
PowerShell
30 lines
1.4 KiB
PowerShell
|
|
# 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"
|