Long running console applications

Hi I have a console application that lives for a long time. In my Deploy.ps1 I issue a command to launch this application. The problem is that The deployment step never completes presumably because the console application has not terminated.

Is there a way to get around this?

Kind Regards.

Hi,

Thanks for reaching out. By your question, i’m assuming it is Ok to move on with the deployment even if this console application hasn’t finished running (correct me if i’m wrong). If that is the case, then try to start the application using the start-process cmdlet. This will open a new process that will run this application on the background so your Deploy.ps1 wont be sitting there waiting for the application to finish.

Hope that helps

Dalmiro

Hi Dalmiro,
Thanks that solved the issue! Keep up the good work everything about Octopus Deploy is awesome!

Glad to hear.

Cheers!

This actually didn’t work for me in 2.6.5. I used Start-Process for a long-lived EXE, the Deploy.ps1 script did indeed exit, but Octopus never completed the deployment. It’ll only complete if I kill the process that was launched with Start-Process.

Start-Process -FilePath "$DeployFolder\$Application" -WorkingDirectory "$DeployFolder" -WindowStyle Hidden -RedirectStandardOutput "$LogFolder\output.log" -RedirectStandardError "$LogFolder\error.log"

Also tried wrapping Start-Process in a Job – no dice (the job and Deploy.ps1 exit properly, but the deployment hangs).

Start-Job -ScriptBlock {
        Param(
            [string]$Application,
            [string]$DeployFolder,
            [string]$LogFolder
        )
        Start-Process -FilePath "$DeployFolder\$Application" -WorkingDirectory "$DeployFolder" -WindowStyle Hidden -RedirectStandardOutput "$LogFolder\output.log" -RedirectStandardError "$LogFolder\error.log"
    } -ArgumentList $Application, $DeployFolder, $LogFolder | Wait-Job

Hi Dhorn - I’ve answered you on your other ticket: http://help.octopusdeploy.com/discussions/praoblems/36008-deployment-never-completes-but-deployps1-exits-successfully

Hey Dalmiro,

This may be helpful. I literally swapped our EXE with notepad.exe and shipped it through the pipeline. Interesting, that worked. So, there’s something that our EXE is doing that Octopus seems to want to hang on to. What could an EXE be doing that would cause Octopus to hang even though the Deploy.ps1 script exits properly?

Unfortunately I can’t distribute the binaries as they’re proprietary.

Could we just hop on a webex? I can set one up and show you the issue. Maybe in an hour?

-Drew

Dalmiro,

I think I know the issue. The EXE is a long-running console app, it never exits (it should be a service, but it is what it is – a console app). Since it never terminates, Octopus hangs during the deployment indefinitely. The workaround seems to be to wrap the EXE with the windows task scheduler and have Octopus manage the scheduler for starting the service instead of starting the EXE directly.

I’ll let you know if this works.

-Drew

From: Horn, Drew
Sent: Wednesday, July 15, 2015 2:56 PM
To: 'Dalmiro Grañas’
Subject: RE: Long running console applications [Questions #4448]

Hey Dalmiro,

This may be helpful. I literally swapped our EXE with notepad.exe and shipped it through the pipeline. Interesting, that worked. So, there’s something that our EXE is doing that Octopus seems to want to hang on to. What could an EXE be doing that would cause Octopus to hang even though the Deploy.ps1 script exits properly?

Unfortunately I can’t distribute the binaries as they’re proprietary.

Could we just hop on a webex? I can set one up and show you the issue. Maybe in an hour?

-Drew

Hi Drew,

Unfortunately, since this is something strictly related to you console app, I don’t think there’s gonna by much point in setting up a call.

The scheduled task approach is definitely a good idea.

Thanks,

Dalmiro

Well this isn’t strictly related to our console app, it’s an issue for any long-lived console app.

Regardless, the scheduled task approach is working, so we’re good here.

Thanks for your help.

Sent from my iPhone