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.
- package/package.json +1 -1
- package/scripts/start.ps1 +15 -16
package/package.json
CHANGED
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
|
-
#
|
|
122
|
-
$
|
|
123
|
-
$
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
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
|
-
$
|
|
134
|
-
|
|
135
|
-
Start-Sleep -Seconds
|
|
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
|
-
|
|
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
|
|