Update service port from 5000 to 2414 and adjust related configurations

This commit is contained in:
Phoenix
2025-08-07 17:53:54 +08:00
parent d6efa9163b
commit f2a0818d0e
11 changed files with 11 additions and 104 deletions
+1 -1
View File
@@ -12,7 +12,7 @@
"Kestrel": {
"Endpoints": {
"Http": {
"Url": "http://*:5000"
"Url": "http://*:2414"
}
}
},
+7 -7
View File
@@ -138,11 +138,11 @@ try {
# Configure firewall rule
Write-Host "Configuring Windows Firewall..."
try {
New-NetFirewallRule -DisplayName "Resource Monitor Service" -Direction Inbound -Protocol TCP -LocalPort 5000 -Action Allow -Profile Any -ErrorAction Stop
New-NetFirewallRule -DisplayName "Resource Monitor Service" -Direction Inbound -Protocol TCP -LocalPort 2414 -Action Allow -Profile Any -ErrorAction Stop
Write-Host "Firewall rule created" -ForegroundColor Green
} catch {
Write-Host "WARNING: Failed to create firewall rule. You may need to configure manually." -ForegroundColor Yellow
Write-Host "Manual command: New-NetFirewallRule -DisplayName 'Resource Monitor Service' -Direction Inbound -Protocol TCP -LocalPort 5000 -Action Allow" -ForegroundColor Gray
Write-Host "Manual command: New-NetFirewallRule -DisplayName 'Resource Monitor Service' -Direction Inbound -Protocol TCP -LocalPort 2414 -Action Allow" -ForegroundColor Gray
}
# Start the service
@@ -165,8 +165,8 @@ Write-Host
Write-Host "=== Installation Complete ===" -ForegroundColor Cyan
Write-Host "Service Name: $SERVICE_NAME" -ForegroundColor White
Write-Host "Installation Path: $INSTALL_PATH" -ForegroundColor White
Write-Host "Service URL: http://localhost:5000" -ForegroundColor White
Write-Host "API Health Check: http://localhost:5000/api/health" -ForegroundColor White
Write-Host "Service URL: http://localhost:2414" -ForegroundColor White
Write-Host "API Health Check: http://localhost:2414/api/health" -ForegroundColor White
Write-Host
Write-Host "The service is now running and will start automatically with Windows." -ForegroundColor Green
Write-Host "You can manage it through Services.msc or using PowerShell commands:" -ForegroundColor White
@@ -182,12 +182,12 @@ Write-Host
Write-Host "Testing API endpoint..." -ForegroundColor Yellow
Start-Sleep -Seconds 5
try {
$response = Invoke-RestMethod -Uri "http://localhost:5000/api/health" -TimeoutSec 10
$response = Invoke-RestMethod -Uri "http://localhost:2414/" -TimeoutSec 10
Write-Host "API Test Result: SUCCESS" -ForegroundColor Green
Write-Host "Service Version: $($response.Service)" -ForegroundColor White
Write-Host "Service Version: $($response.Service) v$($response.Version)" -ForegroundColor White
Write-Host "Status: $($response.Status)" -ForegroundColor White
} catch {
Write-Host "API Test Result: FAILED" -ForegroundColor Red
Write-Host "The service may still be starting up. Wait a few minutes and try accessing:" -ForegroundColor Yellow
Write-Host "http://localhost:5000/api/health" -ForegroundColor White
Write-Host "http://localhost:2414/api/health" -ForegroundColor White
}
+3 -3
View File
@@ -58,7 +58,7 @@ sc failure "$SERVICE_NAME" reset=300 actions=restart/5000/restart/5000/restart/1
# Configure firewall rule
echo "Configuring Windows Firewall..."
powershell -Command "New-NetFirewallRule -DisplayName 'Resource Monitor Service' -Direction Inbound -Protocol TCP -LocalPort 5000 -Action Allow -Profile Any" 2>/dev/null
powershell -Command "New-NetFirewallRule -DisplayName 'Resource Monitor Service' -Direction Inbound -Protocol TCP -LocalPort 2414 -Action Allow -Profile Any" 2>/dev/null
# Start the service
echo "Starting service..."
@@ -69,8 +69,8 @@ if [[ $? -eq 0 ]]; then
echo "=== Installation Complete ==="
echo "Service Name: $SERVICE_NAME"
echo "Installation Path: $INSTALL_PATH"
echo "Service URL: http://localhost:5000"
echo "API Health Check: http://localhost:5000/api/health"
echo "Service URL: http://localhost:2414"
echo "API Health Check: http://localhost:2414/api/health"
echo
echo "The service is now running and will start automatically with Windows."
echo "You can manage it through Services.msc or using sc commands:"
-8
View File
@@ -1,8 +0,0 @@
# PowerShell script to create a new inbound rule in Windows Firewall
$port = 5000
$ruleName = "ResourceMonitorServicePublish"
if (Get-NetFirewallRule -DisplayName $ruleName) {
Write-Host "Rule already exists, not creating a new one"
} else {
New-NetFirewallRule -DisplayName $ruleName -Direction Inbound -Protocol TCP -LocalPort $port -Action Allow -Profile Any
}
-4
View File
@@ -1,4 +0,0 @@
sc create ResourceMonitorService binPath="%~dp0ResourceMonitorService.exe --windows-service" start= auto
sc description ResourceMonitorService "A service that monitors system resource usage and exposes it via a web API."
@@ -1,8 +0,0 @@
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.Hosting.Lifetime": "Information"
}
}
}
-19
View File
@@ -1,19 +0,0 @@
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.Hosting.Lifetime": "Information"
}
},
"RunAsWindowsService": true,
"Kestrel": {
"Endpoints": {
"Http": {
"Url": "http://*:5000"
}
}
},
"ApiSettings": {
"ApiKey": "b7f3e8a1-4c2d-4d9f-9a6e-2a1c5d7f8e9a"
}
}
@@ -1,8 +0,0 @@
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.Hosting.Lifetime": "Information"
}
}
}
-19
View File
@@ -1,19 +0,0 @@
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.Hosting.Lifetime": "Information"
}
},
"RunAsWindowsService": true,
"Kestrel": {
"Endpoints": {
"Http": {
"Url": "http://*:5000"
}
}
},
"ApiSettings": {
"ApiKey": "b7f3e8a1-4c2d-4d9f-9a6e-2a1c5d7f8e9a"
}
}
@@ -1,8 +0,0 @@
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.Hosting.Lifetime": "Information"
}
}
}
@@ -1,19 +0,0 @@
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.Hosting.Lifetime": "Information"
}
},
"RunAsWindowsService": true,
"Kestrel": {
"Endpoints": {
"Http": {
"Url": "http://*:5000"
}
}
},
"ApiSettings": {
"ApiKey": "b7f3e8a1-4c2d-4d9f-9a6e-2a1c5d7f8e9a"
}
}