Deploying Windows Service in Stopped State

Is there an option to deploy a Windows Service in Automatic or Automatic Delayed mode but not to Start the service after deployment.

As far as I can see, Octopus automatically starts the service it just installed. Is there an override?

Hi Chris,

Thanks for getting in touch! On your deployment step, towards the bottom you’ll find a field called Start Mode that will let you configure this (see attached screenshot).

On our documentation page we have a video showing how to deploy services. Try to give it a look in case you haven’t already

Hope that helps!

Dalmiro

Right, but that isn’t what I would like. For example, I would like to set Start Mode to “Automatic”, but I would not like to have Octopus Deploy automatically start the Service after installation. See the bolded step below.

sc.exe config DataValidationMonitorService binPath= "D:\Data_Services\DataValidationMonitorService\DataValidationMonitorService.exe" DisplayName= "DataValidationMonitorService" depend= / start= auto
[SC] ChangeServiceConfig SUCCESS
Updating the service description
**[SC] ChangeServiceConfig2 SUCCESS
Starting the DataValidationMonitorService service**

There are a couple of different use cases for this:

  • Some manual intervention is needed before it can be started for the first time
  • Some QA test timing requires it to not be installed in a Started state
  • There are more than 1 Windows Services that need to be installed but not started until all are installed.

I second the request from getmarkus.
We would like to, after stopping several Windows services to allow for DB script runs, to be able to install new or updated services in parallel with the DB script runs, but to not have Octopus start services until we give it the go-ahead.

Thanks!

H̶i̶ ̶J̶i̶m̶,̶

T̶h̶a̶n̶k̶s̶ ̶f̶o̶r̶ ̶r̶e̶a̶c̶h̶i̶n̶g̶ ̶o̶u̶t̶.̶ ̶W̶h̶a̶t̶ ̶y̶o̶u̶ ̶c̶o̶u̶l̶d̶ ̶d̶o̶ ̶i̶s̶ ̶d̶e̶p̶l̶o̶y̶ ̶t̶h̶e̶ ̶s̶e̶r̶v̶i̶c̶e̶ ̶w̶i̶t̶h̶ ̶t̶h̶e̶ ̶s̶t̶a̶r̶t̶ ̶m̶o̶d̶e̶ ̶s̶e̶t̶ ̶a̶s̶ ̶S̶t̶o̶p̶p̶e̶d̶,̶ ̶a̶n̶d̶ ̶t̶h̶e̶n̶ ̶u̶s̶e̶ ̶o̶u̶r̶ ̶W̶i̶n̶d̶o̶w̶s̶ ̶S̶e̶r̶v̶i̶c̶e̶s̶ ̶-̶ ̶S̶t̶a̶r̶t̶ ̶s̶t̶e̶p̶ ̶f̶r̶o̶m̶ ̶t̶h̶e̶ ̶O̶c̶t̶o̶p̶u̶s̶ ̶l̶i̶b̶r̶a̶r̶y̶ ̶w̶h̶e̶n̶ ̶t̶h̶e̶ ̶t̶i̶m̶e̶ ̶i̶s̶ ̶r̶i̶g̶h̶t̶ ̶f̶o̶r̶ ̶t̶h̶e̶ ̶s̶e̶r̶v̶i̶c̶e̶ ̶t̶o̶ ̶b̶e̶ ̶s̶t̶a̶r̶t̶e̶d̶.̶

h̶t̶t̶p̶s̶:̶/̶/̶l̶i̶b̶r̶a̶r̶y̶.̶o̶c̶t̶o̶p̶u̶s̶d̶e̶p̶l̶o̶y̶.̶c̶o̶m̶/̶#̶!̶/̶s̶t̶e̶p̶-̶t̶e̶m̶p̶l̶a̶t̶e̶/̶a̶c̶t̶i̶o̶n̶t̶e̶m̶p̶l̶a̶t̶e̶-̶w̶i̶n̶d̶o̶w̶s̶-̶s̶e̶r̶v̶i̶c̶e̶-̶s̶t̶a̶r̶t̶

T̶h̶a̶n̶k̶s̶

The content of this reply was struck through as it was incorrect. Please check my next reply on this thread for a rather less incorrect reply

Dalmiro

Hi Dalmiro,

There is no Stopped mode showing for me, and I’m running version 2.6.4 (the latest) here.
I would need to leave the mode as either Automatic or Manual, depending on whether we normally want the service running or not, and then separately have it stopped.

Jim Locke
Senior Release Engineer
Staples Promotional Products
[cid:image009.jpg@01CF2C9E.9F2F0EF0]

T: 314-812-5802
F: 314-692-3833
jim.locke@staples.commailto:jim.locke@staples.com

www.StaplesPromotionalProducts.comhttp://www.staplespromotionalproducts.com/
8610 Page Ave. Ste A St. Louis, MO 63114

[cid:image002.jpg@01CF2C9E.5F628220]http://yourbrandpartner.com/[cid:image003.jpg@01CF2C9E.5F628220]https://www.facebook.com/StaplesPromo[cid:image004.jpg@01CF2C9E.5F628220]http://www.pinterest.com/staplespromo/[cid:image005.jpg@01CF2C9E.5F628220]http://www.linkedin.com/company/staples-promotional-products[cid:image006.jpg@01CF2C9E.5F628220]https://twitter.com/staplespromo[cid:image007.jpg@01CF2C9E.5F628220]http://www.youtube.com/channel/UCmxxNNNsPGHR6LqO6b08K3Q[cid:image008.jpg@01CF2C9E.5F628220]https://plus.google.com/+Staplespromotionalproducts/posts

This electronic mail message contains CONFIDENTIAL information which is intended only for the use of the Addressee(s) named herein. If you are not an Addressee, or the person responsible for delivering this to an Addressee, you are hereby notified that reading, copying, or distributing this message is prohibited. If you have received this electronic mail message in error, please reply to the sender and take the steps necessary to delete the message completely from your computer system.

image006.jpg

image005.jpg

image004.jpg

image001.jpg

image003.jpg

image008.jpg

image002.jpg

image007.jpg

Hi Jim,

I deeply apologize for the wrong information, my head was someplace else. I’ll cross out that reply so no one gets confused by it again.

When the user sets the startup mode as “Automatic”, we start it by default. There is a uservoice suggestion to change this approach. Try to put some votes on it if you want to see it implemented in the future:

As a workaround you can do this:

  1. Set startup mode to “manual”. This way the service wont be started after the configuration.

  2. Add this snippet as a post build script on your Nuget deploy step
    Set-Service -name $OctopusParameters['Octopus.Action[YourDeployStepName].WindowsService.ServiceName'] -StartupType Automatic

(make sure to change the step name on it)

That way the service will be set to “Automatic” but it wont be started right away. It’ll be up to you to start it afterwards.

Thanks and again sorry for the previous incorrect information.

Dalmiro

Dalmiro, I appreciate the script here, as it helped us out quite a bit. We deploy 12+ services at a time with OctopusDeploy, and this will help us resolve this issue as well.

For other people looking at this, I might suggest a minor tweak to this script:
Set-Service -name
$OctopusParameters[‘Octopus.Action[#{Octopus.Action.Name}].WindowsService.ServiceName’]
-StartupType Automatic

By using the #{Octopus.Action.Name} you can use a single generic line for any step. If you’re doing more than one script, it does make this easier to maintain.

Though hopefully the feature gets enough votes that this isn’t even a concern!

This also caused us an issue. Thanks Dalmiro for the workaround. I would vote for the ability to be able to configure a service and not start it right away.

We have exactly the same issue with configuring websites via Octopus and them being started immediately (where we don’t want them to be).

For those needing to set the service to “Automatic (Delayed)” there didn’t seem to be an option to do this via Set-Service, so I ended up using sc.exe directly in the post deploy powershell script, with Shaun’s neat variable trick as above (thanks Shaun):

sc.exe config $OctopusParameters['Octopus.Action[#{Octopus.Action.Name}].WindowsService.ServiceName'] start= delayed-auto