How to start/stop/restart a node.js server process from Bamboo?

I have the following requirement, and would like to understand how to do this from Bamboo:

  • Run a build using tools like Grunt - this is not a problem, that's already working through the script task.
  • The result of the build is a directory (or artifact) that contains all of the node/npm dependencies of the project.
  • The project contains a JavaScript file that I need to run using the `node` executable. It will start a Node.js Connect/Express server.
  • This server process is supposed to keep running once the build is over.

What are my options for doing this? Some ideas I've had:

  • Start the node process from a script using `node index.js &` (or `nohup`) to keep it running. In this scenario, I would need to kill the previous instance of the server before starting the new one.
  • Have something like `nodemon` run the server continuously outside of Bamboo, copy over the directory/artifact as the last (deployment) step in the build.

Any other ideas? How have other people solved this?

 

 

1 answer

Hi Nils,

We run our node servers using forever (npm package) and init scripts based on http://blog.podrezo.com/init-d-startupshutdown-script-for-node-js-applications-via-forever/.

So when we are deploying the applications we do the following from a SSH Task:

  • execute /etc/init.d/ournodeserver stop
  • unpack our artifact to the correct path
  • execute /etc/init.d/ournodeserver start

We are using deployment projects in Bamboo, our builds only create packages that we deploy into several environments.

Thanks for the reply - this looks great. I've done some research and it looks like I'll be using a similar approach using forever + nodemon. Since it's just a test system, I probably won't integrate with init.d.

Suggest an answer

Log in or Sign up to answer
Atlassian Community Anniversary

Happy Anniversary, Atlassian Community!

This community is celebrating its one-year anniversary and Atlassian co-founder Mike Cannon-Brookes has all the feels.

Read more
Community showcase
Renan Battaglin
Published May 18, 2017 in Bamboo

FAQ: How to Upgrade Bamboo Server

Bamboo 5.9 will no longer be supported after June 12, 2017. What does this mean? As part of our End of Life policy, Atlassian supports major versions for two years after the first major iteratio...

1,493 views 0 5
Read article

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you