Deploy not waiting for service to stop

We have a service that can take 10 -20 seconds to stop and when we deploy it using Octopus the deployment fails. The reason looks like the tentacle does not wait long enough for the service to stop and the dlls still have something holding them. All I’m doing is putting this in the predeploy.ps1

Stop-Service Application1 -force

Do I need to put a sleep in the script so it waits longer?

Hi - a sleep is probably the quickest option, so long as the stop time is reliably under whatever value you sleep for.

You could also consider using:

sc.exe query MyServer

in a loop to check for the Stopped status, though some care would be needed to ensure this doesn’t loop forever under a variety of conditions.

Hope this helps,
Nick

Thank you! This resolved the issue, but it feels dirty…Seems like Octopus could be smart enough to know how to handle this situation. But maybe it’s not Octopus’s job to know. I’ll leave that up to you guys to decide!

Thanks,
Dan