Search code examples
node.jsdeploymentforever

Nodejs forever deployment


I am working on project of Nodejs, this is the first time we have started working on nodejs. I am running few node scripts in forever demon, everytime if there is any update in those scripts I need to restart those scripts again, also where there are new script added I need to add them manually in forever command.

Is there any deployment tool / mechanism which can take care of restarting or starting nodejs script as soon as they are deployed on server?


Solution

  • I would use PM2 in favour of forever, and then use it's Watch & Restart functionality, explained here. It will then automatically restart your app when a file changes in the current directory or its subdirectories

    enter image description here

    If you want to stick with forever, it also supports similar functionality through the use of the -w, --watch flag which can either be passed as a parameter or loaded via the config file. Have a look at their README here