26 lines
897 B
PowerShell
26 lines
897 B
PowerShell
Function Stop-Server {
|
||
param (
|
||
[Parameter(Mandatory=$true)]
|
||
[string] $server_name
|
||
)
|
||
Write-Host "Stopping $server_name"
|
||
|
||
# 如果存在具有相同名称的 PowerShell Job,将其终止
|
||
$existing_job = Get-Job -Name $server_name -ErrorAction SilentlyContinue
|
||
if ($null -ne $existing_job) {
|
||
Write-Host "Terminating job for $server_name"
|
||
Stop-Job -Name $server_name
|
||
Remove-Job -Name $server_name
|
||
}
|
||
else {
|
||
Write-Host "No job found for $server_name"
|
||
}
|
||
}
|
||
|
||
# 列出所有服务器目录
|
||
$server_dirs = "backend", "canteen", "data-transfer", "home-user-auth", "inventory", "map-library", "orders", "product", "product-model", "product-template", "shopping-cart-confirmation", "upload", "webset"
|
||
|
||
# 停止每个服务器的 PowerShell Job
|
||
foreach ($server_dir in $server_dirs) {
|
||
Stop-Server -server_name $server_dir
|
||
} |