Deploying console apps best practise

We are new to Octopus Deploy and currently trialing the app. Running into a number of difficulties but here is one of them!

As part of our deployment there are a number of console apps. I have setup a process to add the files and am using a powershell script to first stop the process if it is running like this:

Get-Process MyApp -ErrorAction SilentlyContinue | Foreach-Object { $_.CloseMainWindow() | Out-Null } | stop-process –force

And then post deployment, we start the process using:
Start-Process ($OctopusParameters["Octopus.Action.Package.InstallationDirectoryPath"] + "\MyApp.exe")

However we found that there were multiple processes being started and cannot work out why. As a bad workaround we added the stop-process line just before the start so that it would stop anything that was already running. This did not seem to help.

Do you have any recommendations of best practise for this?

Thanks

Hi David,

Thanks for getting in touch.

The way you have configured the deployment seems reasonable to me, I would expect all matching process to get killed and a single new one to start. Could you send the deployment logs so I can have and look, something may stand out? There are instructions here for getting the deployment log, send it to support@octopus.com to protect your privacy.

Can I help with the other difficulties you’ve run into?

Cheers,
Shane

I am not sure why we were getting multiple apps starting but that seems to have stopped.

There is still an issue with one of the apps though. For whatever reason it never started. We are able to start it ourselves manually but Octopus never starts it. If you still have the previous logs (this online thread does not seem to show the full conversation that we have had via email) then this is the app ZDScheduleNotifier. I am adding it here: ServerTasks-381.log.txt (141.4 KB)

The only thing I can think of is that this starts a service broker in SQL Server. I am not sure if any special rights are required for Octopus Deploy to start that. We have put a try catch around that but are not seeing any logging in our local log files.

If you have any thoughts it would be most appreciated.

Thanks

David

Hi David,

How are you starting ZDScheduleNotifier? After you attempt to start it what is the value of $LastExitCode?

To rule out being a permissions issue you can try stopping the Tentacle service and then start it via the command line by running C:\Program Files\Octopus Deploy\Tentacle\Tentacle.exe. This will run Tentacle with the permissions of the current user rather than SYSTEM. If you can successfully start ZDScheduleNotifier then it would indicate a permissions issue.

Cheers,
Shane

Hi Shane,

That worked. I started it using the “agent” parameter. (Your instructions did not say which parameter to use but I assumed that would be OK). I then deployed it and it started the console app as expected.

I suppose I need to give SYSTEM the rights it needs but I am not quite sure what they are…

David

Hi David,

You can run the Tentacle service as a specific user account if that helps: https://octopus.com/docs/infrastructure/deployment-targets/windows-targets/running-tentacle-under-a-specific-user-account

Cheers,
Shane

Thanks, we actually solved it by changing the sql server user so that it was a specific user with the rights needed.

Thanks

David

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.