Deploying to an EXE that is in use

I’d like to find out how to properly handle deploying an EXE, when that application is in use sometimes (like a scheduled task). Currently, if the exe is running, Octopus fails the deployment, as it is unable to clear the folder and deploy.

Hi Jeremy,

Thanks for getting in touch! You’re correct - your service would need to stop running before deploying. If it’s a Windows service, we have a couple of steps in our library to disable/enable them which may be helpful.
https://library.octopusdeploy.com/step-templates/1be30b21-ba58-4667-bff4-2d0ef9a806af/actiontemplate-windows-scheduled-task-disable
https://library.octopusdeploy.com/step-templates/c5b985a0-14ed-4364-a1c1-6a1dc65500ed/actiontemplate-windows-scheduled-task-enable

If it’s another process, you would need to use a PowerShell script that safely stops your service, then deploy.

Let me know how you go and if you have any further questions!

Best regards,

Kenny

Currently the exe runs as a windows scheduled task. A powershell script could tell when it is running based on the process name. Stopping it while running would be bad.

Jeremy A. Cunningham
TwentyEighty


Hi Jeremy,

Thanks for following up so quickly! You’re correct, and I’m sorry that my first reply was a bit vaguely worded. What I would do is have a PowerShell script that checks if the task is running, and waits until it’s done. Only when that happens let the deployment continue.

Best regards,

Kenny

How do I avoid Octopus timing out waiting for the powershell to return?

Jeremy A. Cunningham
TwentyEighty


Hi Jeremy,

Octopus doesn’t timeout, so you shouldn’t run into any issues here. That’s unless your script includes a timeout exception. Have you hit any issues?

Kind regards,

Kenny

I haven’t tried yet. I just presumed. :slight_smile: Thank you for the info!

Jeremy A. Cunningham
Senior Application Development Manager

Colorado

[cid:image002.jpg@01D050FB.3DD643D0]http://www.twentyeighty.com/

image001.jpg

Hi Jeremy,

That’s not a problem! Don’t hesitate to get in touch if you have any further questions or concerns. :slight_smile:

Best regards,

Kenny