How to run next Step with current Step's ps1 script is still running

Basically, I have 4 ‘Steps’ in Octopus ‘Process’:

  1. Start a VM
  2. Run a PowerShell script in the target machine. The ps script contains “npm run xxxxxx” to build a node project website and keep the website running in local, so that I can do something against it after Octopus deploy.
    P.S.: It purposely needs to keep the ps1 NOT closed to keep the node server up and running.
  3. Run a PowerShell script to PING local:Port to check if the NPM build is down(i.e: the website is up and running in local)
  4. Once the website is up, do some cleanup task and finish the deployment

The problem I’m having is:
The Process hangs at Step2 because the ps1 script is always running to keep the website on, Octopus recon itself should wait for ps1 in Step2 ends before executing Step3.

What I would like to know:
Is there any way that I can keep the script in Step 2 running, but move on and execute Step 3, Step 4, etc… That is to say:
Even after the deployment is finished, the script in Step 2 is still running so that website is still running in local.

I have tried run Step 2 and Step 3 in parallel but Step3 got an error: “Cannot start this task yet because “ServerTasks-84213” (has a write lock) tasks are currently running and this task cannot be run in conjunction with any other tasks. Please wait…

Thank you in advance!!!

Hi! Thanks for your question.

Octopus doesn’t directly support starting background processes, as reaching the end of the script is how it knows the script has completed and succeeded. However, there are other ways you could achieve your objective.

One way is to use the Start-Process or Start-Job Powershell commands. This should allow you to spawn a new process to run the webserver in.

Another option is to run the webserver in something a little more robust, like a windows service. The node-windows npm package may assist which this (Note, I haven’t used this package myself).

Hopefully one of those options is suitable for your requirements. Let me know if that helps, and if I can assist further!


Hi Jayden,

Thanks for your quick response.

I tried Start-Proess and Start-job but it still get the depedency issue, it not know if the script is completed or not.

But lucky I finally find a solution for it:
use something called NSSM, the whole process would be like:

  1. Octopus Step will start a PowerShell script
  2. the PowerShell script will launch NSSM (the ps1 script will be completed as long as NSSM is called, no matter success or failure. In this way we will complete this Octopus Step and treat NSSM as an async/background task)
  3. [As an Async/background task:] NSSM will launch a bat file or something else to run the NPM build.
  4. At the same time with above async/background task, Octopus execute subsequent Steps.


Excellent, I’m glad you were able to find a good solution!

Thank you for getting in touch, and please contact us again if we can assist you further.


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