fusenapi/run_all_server.ps1

34 lines
1.0 KiB
PowerShell

Function Run-Server {
param (
[Parameter(Mandatory=$true)]
[string] $server_name
)
Write-Host "Running $server_name"
# 导航到相应的目录
Set-Location -Path "server/$server_name"
# 使用 PowerShell Jobs 运行 go run <server_name>.go
Start-Job -Name $server_name -ScriptBlock { go run $server_name.go }
# 返回到上一级目录
Set-Location -Path ".."
}
# 列出所有服务器目录
$server_dirs = "backend", "canteen", "data-transfer", "home-user-auth", "inventory", "map-library", "orders", "product", "product-model", "product-template", "shopping-cart-confirmation", "upload", "webset"
# 在每个服务器目录下运行相应的 go 程序
foreach ($server_dir in $server_dirs) {
Run-Server -server_name $server_dir
}
# 定义目录和screen名称
$dir_path = "./proxyserver"
$screen_name = "proxyserver"
# 进入目录
Set-Location -Path $dir_path
# 启动新的 PowerShell Job 并运行 go 程序
Start-Job -Name $screen_name -ScriptBlock { go run main.go }