NodeJS Forever

Forever is NodeJS cli package for running node scripts continuously.

When you create some node app and want to run it on your VPS you cannot just ssh to server and run node index.js. You need to run it for a long time. Forever ensures that your app is always running.

To install forever you will need node and npm. Install it npm install -g forever.

To start script index.js and scripts are located under scripts dir you would have these kind of scripts.


BASEDIR=$(dirname $0)
echo "Writing logs to ${LOGS}"
mkdir $LOGS
touch "${LOGS}/.gitignore"
echo "*" > "${LOGS}/.gitignore"
forever start -e "${LOGS}/error.log" -o "${LOGS}/out.log" -a "${BASEDIR}/../index.js"


BASEDIR=$(dirname $0)
forever stop "${BASEDIR}/../index.js"


I plan to write more articles about common laravel components. If you are interested let’s stay in touch.
comments powered by Disqus