Running a node application on a local machine is easy - you just execute node app.js
or, if you want to ease the development process, you use nodemon
or forever
.
Things get a little bit more complicated when you decide to go live with the app and want it stable on the production server.
This post describes how to get your application running as a service on CentOS Linux using init
scripts and monit
for managing and monitoring it.
Let's say you have a nodejs application located on your server in /var/www/myapp
and the main script is index.js
.
First thing to do is to add your app to init scripts. To do so, create a new file in /etc/init.d
and name it after your application.