I’m experimenting with Octopus and liking it very much, however I have a particular deployment scenario I can’t figure out how to get to work. Occasionally we need to take our distributed system offline when performing an upgrade to provide us with a window when we can perform data migrations etc. I know this is far from ideal but unfortunately is just how we have to do some upgrades until we implement a better solution. How can I undeploy a release, effectively taking the environment offline?
Our deployment is a (Topshelf) Windows Service which can be installed via PostDeploy.ps1. What I find odd is that to stop and uninstall a release’s Windows Service I need to deploy a new release which does this in the PreDeploy.ps1. I initially thought there would be an Undeploy.ps1 but I can’t find any documentation on something like this. So I guess I could create a special release that just stops Services, but if more needs to be done to undeploy a release, then this knowledge really needs to be contained within the deployed release, not the next release I want to deploy. Hope that makes sense.
Please can you tell me how I can facilitate this deployment scenario with Octopus Deploy? Thanks
Not sure if I totally understand the question, but if I understand, you just need to stop the Topshelf service at the beginning of the deployment?
If this is the case, could you use a PowerShell step in Octopus to simply run
Stop-Service YourService, and make it the first step of your deployment?
If I’ve missed something please let me know. Hope that helps,
Thanks for coming back to me. The scenario I would like to facilitate is taking down the deployed environment (stopping all instances of deployed services), performing data migrations etc, then deploying a new release.
I’m still exploring what Octopus can do, so I’m not sure how to facilitate this, but the actions that could solve this is to instruct Octopus to undeploy the current release (this would invoke UnDeploy.ps1 so I can stop Services). Then once I have done data migration I would instruct Octopus to deploy the new release.
I’m not sure Octopus works this way so I’d like to know how I could achieve the same result? Thanks.
An Octopus deployment can consist of many steps, some based on NuGet package and others PowerShell etc.
You might investigate making the first step in your deployment process a “take offline” step that runs PowerShell to stop services on all of the appropriate machines.
You can then insert a Manual step in the deployment so that it pauses, if necessary, between stopping the services and the installation of the new version (which would be step 3).
You can get quite powerful recipes assembled this way - let me know if you need more info.