From f2a0818d0e75d1631b9273bd12120ab6120f5ccc Mon Sep 17 00:00:00 2001 From: Phoenix Date: Thu, 7 Aug 2025 17:53:54 +0800 Subject: [PATCH] Update service port from 5000 to 2414 and adjust related configurations --- appsettings.json | 2 +- install-service.ps1 | 14 +++++++------- install-service.sh | 6 +++--- publish/configure_firewall.ps1 | 8 -------- publish/install-service.bat | 4 ---- publish/publish/appsettings.Development.json | 8 -------- publish/publish/appsettings.json | 19 ------------------- .../publish/appsettings.Development.json | 8 -------- publish/publish/publish/appsettings.json | 19 ------------------- .../publish/appsettings.Development.json | 8 -------- .../publish/publish/publish/appsettings.json | 19 ------------------- 11 files changed, 11 insertions(+), 104 deletions(-) delete mode 100644 publish/configure_firewall.ps1 delete mode 100644 publish/install-service.bat delete mode 100644 publish/publish/appsettings.Development.json delete mode 100644 publish/publish/appsettings.json delete mode 100644 publish/publish/publish/appsettings.Development.json delete mode 100644 publish/publish/publish/appsettings.json delete mode 100644 publish/publish/publish/publish/appsettings.Development.json delete mode 100644 publish/publish/publish/publish/appsettings.json diff --git a/appsettings.json b/appsettings.json index ee97cee..ccf3d10 100644 --- a/appsettings.json +++ b/appsettings.json @@ -12,7 +12,7 @@ "Kestrel": { "Endpoints": { "Http": { - "Url": "http://*:5000" + "Url": "http://*:2414" } } }, diff --git a/install-service.ps1 b/install-service.ps1 index 5dcb53d..4ccecca 100644 --- a/install-service.ps1 +++ b/install-service.ps1 @@ -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 } diff --git a/install-service.sh b/install-service.sh index 4863b5d..4345dbc 100644 --- a/install-service.sh +++ b/install-service.sh @@ -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:" diff --git a/publish/configure_firewall.ps1 b/publish/configure_firewall.ps1 deleted file mode 100644 index 143c5cd..0000000 --- a/publish/configure_firewall.ps1 +++ /dev/null @@ -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 -} diff --git a/publish/install-service.bat b/publish/install-service.bat deleted file mode 100644 index 808fc57..0000000 --- a/publish/install-service.bat +++ /dev/null @@ -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." - - diff --git a/publish/publish/appsettings.Development.json b/publish/publish/appsettings.Development.json deleted file mode 100644 index b2dcdb6..0000000 --- a/publish/publish/appsettings.Development.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "Logging": { - "LogLevel": { - "Default": "Information", - "Microsoft.Hosting.Lifetime": "Information" - } - } -} diff --git a/publish/publish/appsettings.json b/publish/publish/appsettings.json deleted file mode 100644 index 78a1652..0000000 --- a/publish/publish/appsettings.json +++ /dev/null @@ -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" - } -} diff --git a/publish/publish/publish/appsettings.Development.json b/publish/publish/publish/appsettings.Development.json deleted file mode 100644 index b2dcdb6..0000000 --- a/publish/publish/publish/appsettings.Development.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "Logging": { - "LogLevel": { - "Default": "Information", - "Microsoft.Hosting.Lifetime": "Information" - } - } -} diff --git a/publish/publish/publish/appsettings.json b/publish/publish/publish/appsettings.json deleted file mode 100644 index 78a1652..0000000 --- a/publish/publish/publish/appsettings.json +++ /dev/null @@ -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" - } -} diff --git a/publish/publish/publish/publish/appsettings.Development.json b/publish/publish/publish/publish/appsettings.Development.json deleted file mode 100644 index b2dcdb6..0000000 --- a/publish/publish/publish/publish/appsettings.Development.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "Logging": { - "LogLevel": { - "Default": "Information", - "Microsoft.Hosting.Lifetime": "Information" - } - } -} diff --git a/publish/publish/publish/publish/appsettings.json b/publish/publish/publish/publish/appsettings.json deleted file mode 100644 index 78a1652..0000000 --- a/publish/publish/publish/publish/appsettings.json +++ /dev/null @@ -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" - } -}