[restart_all_servers.bat]
This commit is contained in:
@@ -288,6 +288,32 @@ function Stop-ExistingServers {
|
||||
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 {
|
||||
param(
|
||||
[string] $FilePath,
|
||||
@@ -300,10 +326,12 @@ function Invoke-LoggedCommand {
|
||||
$stderrPath = Join-Path $logDir ($LogName -replace "\.log$", ".stderr.log")
|
||||
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
|
||||
$proc = Start-Process `
|
||||
-FilePath $FilePath `
|
||||
-ArgumentList $Arguments `
|
||||
-ArgumentList $quotedArgs `
|
||||
-WorkingDirectory $WorkingDirectory `
|
||||
-RedirectStandardOutput $logPath `
|
||||
-RedirectStandardError $stderrPath `
|
||||
@@ -338,10 +366,12 @@ function Start-LoggedServer {
|
||||
[Environment]::SetEnvironmentVariable($key, [string] $Environment[$key], "Process")
|
||||
}
|
||||
|
||||
$quotedArgs = Quote-ProcessArguments -Arguments $Arguments
|
||||
|
||||
try {
|
||||
$proc = Start-Process `
|
||||
-FilePath $FilePath `
|
||||
-ArgumentList $Arguments `
|
||||
-ArgumentList $quotedArgs `
|
||||
-WorkingDirectory $WorkingDirectory `
|
||||
-RedirectStandardOutput $stdout `
|
||||
-RedirectStandardError $stderr `
|
||||
|
||||
Reference in New Issue
Block a user