langmart-gateway-type3 3.0.47 → 3.0.48

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 +15 -16
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "langmart-gateway-type3",
3
- "version": "3.0.47",
3
+ "version": "3.0.48",
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,29 +118,28 @@ $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
- # 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"
121
+ # Create a VBS wrapper to truly detach the process (survives SSH disconnect)
122
+ $vbsFile = Join-Path $InstallDir "start-gateway.vbs"
123
+ $vbsContent = @"
124
+ Set WshShell = CreateObject("WScript.Shell")
125
+ WshShell.CurrentDirectory = "$($InstallDir -replace '\\', '\\')"
126
+ WshShell.Environment("Process")("GATEWAY_PORT") = "$GatewayPort"
127
+ WshShell.Environment("Process")("PLATFORM_URL") = "$GatewayPlatform"
128
+ WshShell.Environment("Process")("GATEWAY_API_KEY") = "$GatewayApiKey"
129
+ WshShell.Environment("Process")("GATEWAY_ID") = "$GatewayIdValue"
130
+ WshShell.Environment("Process")("NODE_ENV") = "production"
131
+ WshShell.Run "cmd /c node ""$($EntryFile -replace '\\', '\\')"" > ""$($LogFile -replace '\\', '\\')"" 2> ""$($ErrorLogFile -replace '\\', '\\')"" ", 0, False
132
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
133
+ $vbsContent | Out-File -FilePath $vbsFile -Encoding ASCII
134
+ Start-Process -FilePath "wscript.exe" -ArgumentList "`"$vbsFile`"" -WindowStyle Hidden -Wait
135
+ Start-Sleep -Seconds 3
136
136
  # Get the actual node process PID
137
137
  $nodePid = (Get-NetTCPConnection -LocalPort $GatewayPort -State Listen -ErrorAction SilentlyContinue).OwningProcess | Select-Object -First 1
138
138
  if ($nodePid) {
139
139
  $nodePid | Out-File -FilePath $PidFile -Encoding ASCII
140
140
  Write-Log "Process started with PID: $nodePid"
141
141
  } else {
142
- $process.Id | Out-File -FilePath $PidFile -Encoding ASCII
143
- Write-Log "Process started with PID: $($process.Id)"
142
+ Write-Log "Process starting... checking shortly"
144
143
  }
145
144
  } catch { Write-Log "Failed to start gateway: $_" "ERROR"; Write-Output "RESULT:running=false,port=,pid=,mode=standalone"; exit 1 }
146
145