forked from meswork/HL_MES_manager_ai
Add HL MES manager with AI assistant service
This commit is contained in:
25
ai-mcp-service/start.ps1
Normal file
25
ai-mcp-service/start.ps1
Normal file
@@ -0,0 +1,25 @@
|
||||
$ErrorActionPreference = 'Stop'
|
||||
|
||||
$serviceDir = Split-Path -Parent $MyInvocation.MyCommand.Path
|
||||
$port = if ($env:PORT) { [int]$env:PORT } else { 8787 }
|
||||
$url = "http://127.0.0.1:$port/health"
|
||||
|
||||
try {
|
||||
$health = Invoke-RestMethod -Uri $url -Method Get -TimeoutSec 2
|
||||
Write-Host "AI MCP service is already running: $url"
|
||||
$health | ConvertTo-Json -Depth 5
|
||||
exit 0
|
||||
} catch {
|
||||
Write-Host "Starting AI MCP service on $url ..."
|
||||
}
|
||||
|
||||
Start-Process -FilePath "node" -ArgumentList "server.js" -WorkingDirectory $serviceDir -WindowStyle Hidden
|
||||
Start-Sleep -Seconds 2
|
||||
|
||||
try {
|
||||
$health = Invoke-RestMethod -Uri $url -Method Get -TimeoutSec 5
|
||||
Write-Host "AI MCP service started: $url"
|
||||
$health | ConvertTo-Json -Depth 5
|
||||
} catch {
|
||||
Write-Error "AI MCP service failed to start. Run 'npm start' in this directory to see details."
|
||||
}
|
||||
Reference in New Issue
Block a user