langmart-gateway-type3 3.0.46 → 3.0.47

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/package.json +1 -1
  2. package/scripts/start.ps1 +24 -3
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "langmart-gateway-type3",
3
- "version": "3.0.46",
3
+ "version": "3.0.47",
4
4
  "description": "LangMart Type 3 Gateway - Seller-Managed Gateway with Local Vault",
5
5
  "main": "dist/index-server.js",
6
6
  "types": "dist/index-server.d.ts",
package/scripts/start.ps1 CHANGED
@@ -118,9 +118,30 @@ $env:GATEWAY_PORT = $GatewayPort; $env:PLATFORM_URL = $GatewayPlatform; $env:GAT
118
118
  Write-Log "Starting with: node $EntryFile"
119
119
  try {
120
120
  $ErrorLogFile = Join-Path $LogDir "gateway-error.log"
121
- $process = Start-Process -FilePath "node" -ArgumentList $EntryFile -WindowStyle Hidden -PassThru -WorkingDirectory $InstallDir -RedirectStandardOutput $LogFile -RedirectStandardError $ErrorLogFile
122
- $process.Id | Out-File -FilePath $PidFile -Encoding ASCII
123
- Write-Log "Process started with PID: $($process.Id)"
121
+ # Use cmd /c start to truly detach the process from SSH session
122
+ $batchFile = Join-Path $InstallDir "start-gateway.bat"
123
+ $batchContent = @"
124
+ @echo off
125
+ cd /d "$InstallDir"
126
+ set GATEWAY_PORT=$GatewayPort
127
+ set PLATFORM_URL=$GatewayPlatform
128
+ set GATEWAY_API_KEY=$GatewayApiKey
129
+ set GATEWAY_ID=$GatewayIdValue
130
+ set NODE_ENV=production
131
+ node "$EntryFile" > "$LogFile" 2> "$ErrorLogFile"
132
+ "@
133
+ $batchContent | Out-File -FilePath $batchFile -Encoding ASCII
134
+ $process = Start-Process -FilePath "cmd.exe" -ArgumentList "/c start /B `"`" cmd /c `"$batchFile`"" -WindowStyle Hidden -PassThru -WorkingDirectory $InstallDir
135
+ Start-Sleep -Seconds 2
136
+ # Get the actual node process PID
137
+ $nodePid = (Get-NetTCPConnection -LocalPort $GatewayPort -State Listen -ErrorAction SilentlyContinue).OwningProcess | Select-Object -First 1
138
+ if ($nodePid) {
139
+ $nodePid | Out-File -FilePath $PidFile -Encoding ASCII
140
+ Write-Log "Process started with PID: $nodePid"
141
+ } else {
142
+ $process.Id | Out-File -FilePath $PidFile -Encoding ASCII
143
+ Write-Log "Process started with PID: $($process.Id)"
144
+ }
124
145
  } catch { Write-Log "Failed to start gateway: $_" "ERROR"; Write-Output "RESULT:running=false,port=,pid=,mode=standalone"; exit 1 }
125
146
 
126
147
  Write-Log "Waiting for gateway to start listening..."