0
votes

I am using Octopus to deploy some Topshelf services that are built by TeamCity. The Octopus deployment runs a powershell script that installs/reinstalls the service from a nuget package and starts it.

My issue is that it is possible for these services to be in the middle of critical activities that should not be interrupted by a new deployment. I would want to wait until the service is finished with these things to deploy my new version. I've not been able to find a nice solution for this. What would be the typical way to handle this situation? Currently my octopus tentacles are set up in "listening" mode.

2

2 Answers

0
votes

One option would be to make your first deployment task a user intervention task. This would mean the new version is built and ready to go, deployment running, but paused. Once you authorise the user intervention task, the deployment would proceed as normal.

If you'd like it to be automated then you could write a Powershell script that polls your service (or its job queue, etc.) and sits in a loop whilst the service is busy; this could be your first deployment step. Once your service is idle, the script can exit with code 0 and your deployment will continue.

0
votes

We had to make related considerations around stubborn or locked processes during Topshelf uninstall/install through Octopus. For your situation, have you looked into the "Before" and "After" Custom Install Actions? Other than that, I like James' notion of polling the process, itself by whatever means. Finally, a perhaps less convenient answer may be to write a Quiesce routine in the application or database.

Custom Install Actions: https://topshelf.readthedocs.io/en/latest/configuration/config_api.html#service-start-modes