BUG: Deploying service with Unchanged doesn't start automatically

When deploying a Windows service, you have the option of setting the Start mode to Unchanged. This is extremely useful for us, since some of our servers may be a cold standby, where the service is installed, but disabled, and active on other servers.

When we use this, though, if the previous installation was Automatic (and running), after deploy, the service is stopped.

Octopus should start the service automatically, if the Start mode is Automatic or if the Start mode is Unchanged and the previous mode before deploy was Automatic.

Also, on a side-note - what happens if you choose Unchanged, and the service was previously not installed? I think we tried this once, and deploy failed. Instead, it should be Automatic (the default).

Hi Lonevvolf,

Thanks for getting in touch! We will have a discussion about how unchanged currently works and if we want to adjust the logic for 3.0.


The side-note probably won’t happen as we should not assume behavior if none currently exist.

Vanessa

I’m having this same problem, running Octopus 3.0.18.2471. The service is initially running and its startup type is Automatic. In the deployment step, the start mode is set to “Unchanged”. I see these messages in the log:

The QWParallelService service already exists; it will be stopped
Stopping the QWParallelService service
Service QWParallelService stopped

Then a bunch of other stuff about the release - configs and whatnot, then:

The QWParallelService service already exists, it will be reconfigured.
sc.exe config "QWParallelService" binPath= "\"C:\Program Files (x86)\qw\QWParallelService\QWParallelService.exe\"" DisplayName= "QWParallelService" depend= "/" obj= "LocalSystem"
[SC] ChangeServiceConfig SUCCESS
Updating the service description
[SC] ChangeServiceConfig2 SUCCESS
The QWParallelService service start mode is set to unchanged, so it won't be started. You will need to start the service manually.

I get these same messages in the log regardless of the service being in a running or a stopped state prior to deployment.

Is this a bug or a feature that I just don’t understand? The intention is to have the service running after the deployment if it was running before, and to have it stay stopped if it was stopped before. The latter condition is met at least, but not the former.

Hi Phinneas,

Thanks for reaching out. The “Startup type” sets how will the service behave when the OS boots. If you want the Service to be at the same state (started or stopped) as it was before the deployment, you’re gonna have to capture its status at the beggining of the deployment in a variable, and then use that variable on a conditional loop to whether start it or not at the end.

This blogpost shows how to create a variable that persists between deployment steps: http://octopusdeploy.com/blog/fun-with-output-variables

If you need help setting this up, let me know.

Dalmiro