
I don’t need to use “forever” here, since i am using respawn which has the same effect. The above script starts when my ec2 start is started fully and make sure nodejs script keeps on running.
#Bitnami nodejs stack code#
Please the above code in /etc/init/nf file #so that i get latest version of my code alwaysĮxec /usr/bin/sudo /opt/bitnami/nodejs/bin/node /home/etech/public_html/pricegenie.in/node/category.js letsdance » /var/log/pg.log 2>&1

#script to start before actual script, pre scriptĬd /home/etech/public_html/pricegenie.in/ #directory where my script is presentĮxec /usr/bin/sudo /usr/bin/git pull -u origin master #respawn is used to start the nodejs again, even if it fails. So if you have a requirement where you want to start a nodejs script on server startup, you need to use upstart. Upstart is basically set of scripts which you can write to start on server startup and on different run levels, more details here. This is achieved using upstart in ubuntu. In most of the cases, it would be a requirement that when you start a new ec2 instance some scripts should start up automatically or maybe some server should start listening on a port etc.

The first step is to choose an AMI, you can go with the a standard 64bit ubuntu based AMI (install nodejs and applications on top if), but i went with a pre-build nodejs AMI by bitnami UpStart Configuration I am assuming you are familiar with the basic setting up an ec2 and starting an instance so won’t describe the basic. The Nodejs script will start automatically on server start up and run forever.

In this blog post, i will share my experiences on setting up NodeJS on EC2 server and various configuration settings involved.
