[restart_all_servers.bat]
This commit is contained in:
@@ -288,6 +288,32 @@ function Stop-ExistingServers {
|
|||||||
Start-Sleep -Milliseconds 800
|
Start-Sleep -Milliseconds 800
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function Quote-ProcessArguments {
|
||||||
|
param([string[]] $Arguments)
|
||||||
|
|
||||||
|
if (-not $Arguments) {
|
||||||
|
return @()
|
||||||
|
}
|
||||||
|
$quoted = @()
|
||||||
|
foreach ($arg in $Arguments) {
|
||||||
|
if ($null -eq $arg) {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
$text = [string] $arg
|
||||||
|
if ($text.Length -eq 0) {
|
||||||
|
$quoted += '""'
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
if ($text -match '\s' -and -not ($text.StartsWith('"') -and $text.EndsWith('"'))) {
|
||||||
|
$escaped = $text -replace '"', '\"'
|
||||||
|
$quoted += '"' + $escaped + '"'
|
||||||
|
} else {
|
||||||
|
$quoted += $text
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return $quoted
|
||||||
|
}
|
||||||
|
|
||||||
function Invoke-LoggedCommand {
|
function Invoke-LoggedCommand {
|
||||||
param(
|
param(
|
||||||
[string] $FilePath,
|
[string] $FilePath,
|
||||||
@@ -300,10 +326,12 @@ function Invoke-LoggedCommand {
|
|||||||
$stderrPath = Join-Path $logDir ($LogName -replace "\.log$", ".stderr.log")
|
$stderrPath = Join-Path $logDir ($LogName -replace "\.log$", ".stderr.log")
|
||||||
Write-Step ("Running {0} {1}" -f (Split-Path -Leaf $FilePath), ($Arguments -join " "))
|
Write-Step ("Running {0} {1}" -f (Split-Path -Leaf $FilePath), ($Arguments -join " "))
|
||||||
|
|
||||||
|
$quotedArgs = Quote-ProcessArguments -Arguments $Arguments
|
||||||
|
|
||||||
Remove-Item -LiteralPath $logPath, $stderrPath -Force -ErrorAction SilentlyContinue
|
Remove-Item -LiteralPath $logPath, $stderrPath -Force -ErrorAction SilentlyContinue
|
||||||
$proc = Start-Process `
|
$proc = Start-Process `
|
||||||
-FilePath $FilePath `
|
-FilePath $FilePath `
|
||||||
-ArgumentList $Arguments `
|
-ArgumentList $quotedArgs `
|
||||||
-WorkingDirectory $WorkingDirectory `
|
-WorkingDirectory $WorkingDirectory `
|
||||||
-RedirectStandardOutput $logPath `
|
-RedirectStandardOutput $logPath `
|
||||||
-RedirectStandardError $stderrPath `
|
-RedirectStandardError $stderrPath `
|
||||||
@@ -338,10 +366,12 @@ function Start-LoggedServer {
|
|||||||
[Environment]::SetEnvironmentVariable($key, [string] $Environment[$key], "Process")
|
[Environment]::SetEnvironmentVariable($key, [string] $Environment[$key], "Process")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$quotedArgs = Quote-ProcessArguments -Arguments $Arguments
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$proc = Start-Process `
|
$proc = Start-Process `
|
||||||
-FilePath $FilePath `
|
-FilePath $FilePath `
|
||||||
-ArgumentList $Arguments `
|
-ArgumentList $quotedArgs `
|
||||||
-WorkingDirectory $WorkingDirectory `
|
-WorkingDirectory $WorkingDirectory `
|
||||||
-RedirectStandardOutput $stdout `
|
-RedirectStandardOutput $stdout `
|
||||||
-RedirectStandardError $stderr `
|
-RedirectStandardError $stderr `
|
||||||
|
|||||||
Reference in New Issue
Block a user