langmart-gateway-type3 3.0.46 → 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.
- package/package.json +1 -1
- package/scripts/start.ps1 +23 -3
package/package.json
CHANGED
package/scripts/start.ps1
CHANGED
|
@@ -118,9 +118,29 @@ $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
|
-
|
|
122
|
-
$
|
|
123
|
-
|
|
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
|
+
"@
|
|
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
|
+
# 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
|
+
Write-Log "Process starting... checking shortly"
|
|
143
|
+
}
|
|
124
144
|
} catch { Write-Log "Failed to start gateway: $_" "ERROR"; Write-Output "RESULT:running=false,port=,pid=,mode=standalone"; exit 1 }
|
|
125
145
|
|
|
126
146
|
Write-Log "Waiting for gateway to start listening..."
|