Now wait for service to be registered before trying to start it
This commit is contained in:
parent
6c97874839
commit
500c40fd42
|
@ -30,18 +30,19 @@ $webclient.DownloadFile($url, $file)
|
||||||
Write-Host "Installing Salt minion..."
|
Write-Host "Installing Salt minion..."
|
||||||
C:\tmp\salt.exe /S
|
C:\tmp\salt.exe /S
|
||||||
|
|
||||||
# Try starting the Salt minion service
|
# Wait for salt-minion service to be registered before trying to start it
|
||||||
Start-Service -Name "salt-minion" -ErrorAction SilentlyContinue
|
|
||||||
$service = Get-Service salt-minion -ErrorAction SilentlyContinue
|
$service = Get-Service salt-minion -ErrorAction SilentlyContinue
|
||||||
$try = 0
|
|
||||||
|
|
||||||
While (!$service) {
|
While (!$service) {
|
||||||
Start-Sleep -s 2
|
Start-Sleep -s 2
|
||||||
$service = Get-Service salt-minion -ErrorAction SilentlyContinue
|
$service = Get-Service salt-minion -ErrorAction SilentlyContinue
|
||||||
}
|
}
|
||||||
|
|
||||||
# Retry starting the service 4 times if it's not running
|
# Start service
|
||||||
# and wait 2 seconds between each try
|
Start-Service -Name "salt-minion" -ErrorAction SilentlyContinue
|
||||||
|
|
||||||
|
# Check if service is started, otherwise retry starting the
|
||||||
|
# service 4 times.
|
||||||
|
$try = 0
|
||||||
While (($service.Status -ne "Running") -and ($try -ne 4)) {
|
While (($service.Status -ne "Running") -and ($try -ne 4)) {
|
||||||
Start-Service -Name "salt-minion" -ErrorAction SilentlyContinue
|
Start-Service -Name "salt-minion" -ErrorAction SilentlyContinue
|
||||||
$service = Get-Service salt-minion -ErrorAction SilentlyContinue
|
$service = Get-Service salt-minion -ErrorAction SilentlyContinue
|
||||||
|
|
Loading…
Reference in New Issue