Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to update a node.js app remotely & automatically

I need to set up automatic remote updates for my app built on nodeJS (not the nodeJS itself).
In my specific case I can't distribute my app as SaaS, so I have to share a copy of app with each client.

I've checked related topics here, but haven't found helpful ones.
Here are a few related questions: one, two

I don't know how to set it up, but I have a few ideas:


old-school way (?) :

  1. use unix cron + shell (or php) script to make «check-request» to «update-server»,
  2. stop nodeJS instance,
  3. replace files with newest ones from tarball,
  4. run nodeJS instance with my app : from shell(?)

It may work if I use my own server, but how can I do the same on, for example, Heroku ?
Overall, it seems weird a bit.


two nodeJS instances way (?) :

  1. use unix cron + another nodeJS app which checks updates on update-server,
  2. then stop one node instance from another && update files
  3. start one nodeJS instance with my app from another : how???

— Is here something else?
— How do folks solve that problem?
— How to realize, for instance, functionality like «Update manager» in Wordpress for nodeJS based app?

like image 353
philipp.b Avatar asked Jun 19 '16 09:06

philipp.b


People also ask

Does node update automatically?

Note: By default, subsequent node pools do not have auto-upgrades enabled.

How do I update node js on Windows server?

There are two simple ways to upgrade: Download the latest Node.js release from its official download page and install the new Node.js release. Install the n module and update Node.js inside the terminal window.


1 Answers

What you're talking about is CI (continuous integration), there are many tools that can help you in the process but they essentially do the same thing.

  1. Detect a change in the code
  2. Pull changes
  3. Build the project
  4. Run tests if there are any
  5. Deploy to the server

— How do folks solve that problem?

Folks use Jenkins, bamboo and many other auto deployment systems. If you're using node with pm2 you can use kinematic that has that build in (one-click deployment feature)

like image 165
dcohenb Avatar answered Oct 14 '22 04:10

dcohenb