I have a socket application, which is created in node js. I was using forever
to run this application. Due to some reason, forever is stopping automatically. I have created a script to check the port is available or not and if the port is free, then start forever using the following script. using bash it is starting, but when we close the terminal, forever is also terminating.
if lsof -Pi :3000 -sTCP:LISTEN -t >/dev/null ; then
echo "running"
else
forever /home/ubuntu/socket_app_modular/server.js start
fi
How to use this script to start forever, if it is not running?
You should put forever process in background:
forever /home/ubuntu/socket_app_modular/server.js start &