We have a step in our deployment process that restarts a Windows Service and on occassion the restart can take hours to complete. This step needs to occur as part of the deployment process. (It’s a restart of a Windows Service which itself uses a RavenDb database–need I say more?)
Anyway, it’s not important to the deployed application, however, that the service is up and running immediately after the app has been deployed. It just needs to be restarted; if it fails to restart, we have other monitoring in place to detect that condition.
I have some PowerShell code in a step action template, but when we simulate a condition where restart of the service would fail, Octopus Deploy is reporting errors even after I have gone through the trouble to use
$WarningActionPreference = 'SilentlyContinue'! It’s very aggravating. Here’s the PowerShell I’m using:
$null = Start-Process PowerShelle.exe -ArgumentList "-NoLogo", "-NonInteractive", "-Command", "$WarningActionPreference = 'SilentlyContinue'; Restart-Service MyServiceName -WarningAction 'SilentlyContinue'" -NoNewWindow
As you can see, I’m trying very hard to not have any warnings displayed. I’ve gone through the trouble of using
Start-Process, swallowing the output (so Octopus can’t implicitly capture it) so that the script will immediately return and Ocotpus would just “move on”. But this is not happening, and Octopus is still waiting around (the step takes about a minute to execute, while that line of PowerShell code on my machine takes less than one second!) and showing warnings emitted from the code executing in a spawned process. What’s going on? How can I prevent this?