feat: Refactor service management scripts to use a unified dev script
- Added package.json to manage development scripts. - Updated restart-services.ps1 to call the new dev script for starting services. - Refactored start-admin.ps1, start-backend.ps1, start-frontend.ps1, and start-mcp.ps1 to utilize the dev script for starting respective services. - Enhanced stop-services.ps1 to improve process termination logic by matching command patterns.
This commit is contained in:
@@ -15,10 +15,6 @@ $ErrorActionPreference = "Stop"
|
||||
$repoRoot = Split-Path -Parent $MyInvocation.MyCommand.Path
|
||||
$stopScript = Join-Path $repoRoot "stop-services.ps1"
|
||||
$devScript = Join-Path $repoRoot "dev.ps1"
|
||||
$frontendScript = Join-Path $repoRoot "start-frontend.ps1"
|
||||
$backendScript = Join-Path $repoRoot "start-backend.ps1"
|
||||
$adminScript = Join-Path $repoRoot "start-admin.ps1"
|
||||
$mcpScript = Join-Path $repoRoot "start-mcp.ps1"
|
||||
|
||||
if (@($FrontendOnly, $BackendOnly, $AdminOnly, $McpOnly).Where({ $_ }).Count -gt 1) {
|
||||
throw "Use only one of -FrontendOnly, -BackendOnly, -AdminOnly, or -McpOnly."
|
||||
@@ -45,46 +41,26 @@ else {
|
||||
Start-Sleep -Seconds 1
|
||||
|
||||
if ($FrontendOnly) {
|
||||
Start-Process powershell -ArgumentList @(
|
||||
"-NoExit",
|
||||
"-ExecutionPolicy", "Bypass",
|
||||
"-File", $frontendScript
|
||||
)
|
||||
Write-Host "[restart] Frontend window restarted." -ForegroundColor Green
|
||||
& $devScript -Only frontend -Spawn
|
||||
Write-Host "[restart] Frontend tab restarted." -ForegroundColor Green
|
||||
exit 0
|
||||
}
|
||||
|
||||
if ($BackendOnly) {
|
||||
Start-Process powershell -ArgumentList @(
|
||||
"-NoExit",
|
||||
"-ExecutionPolicy", "Bypass",
|
||||
"-File", $backendScript,
|
||||
"-DatabaseUrl", $DatabaseUrl
|
||||
)
|
||||
Write-Host "[restart] Backend window restarted." -ForegroundColor Green
|
||||
& $devScript -Only backend -Spawn -DatabaseUrl $DatabaseUrl
|
||||
Write-Host "[restart] Backend tab restarted." -ForegroundColor Green
|
||||
exit 0
|
||||
}
|
||||
|
||||
if ($AdminOnly) {
|
||||
Start-Process powershell -ArgumentList @(
|
||||
"-NoExit",
|
||||
"-ExecutionPolicy", "Bypass",
|
||||
"-File", $adminScript
|
||||
)
|
||||
Write-Host "[restart] Admin window restarted." -ForegroundColor Green
|
||||
& $devScript -Only admin -Spawn
|
||||
Write-Host "[restart] Admin tab restarted." -ForegroundColor Green
|
||||
exit 0
|
||||
}
|
||||
|
||||
if ($McpOnly) {
|
||||
Start-Process powershell -ArgumentList @(
|
||||
"-NoExit",
|
||||
"-ExecutionPolicy", "Bypass",
|
||||
"-File", $mcpScript,
|
||||
"-ApiKey", $McpApiKey,
|
||||
"-BackendApiBase", $BackendApiBase,
|
||||
"-Port", $McpPort
|
||||
)
|
||||
Write-Host "[restart] MCP window restarted." -ForegroundColor Green
|
||||
& $devScript -Only mcp -Spawn -McpApiKey $McpApiKey -McpBackendApiBase $BackendApiBase -McpPort $McpPort
|
||||
Write-Host "[restart] MCP tab restarted." -ForegroundColor Green
|
||||
exit 0
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user