I'm trying to setup a node.js script (Balloons.IO) in production. I've installed forever but anytime server reboot forever list command returns info: No forever processes running Second issue I have setup this script to run under port 9090 which is not allowed by iptables. To fix this other issue I've to run an IPTABLES command to accept incoming connections to port 9090 and IPTABLES keep this config until server restarts...In short, a lot of issues just to launch a node.js script and keep it running.
To fix all these I added this command to crontab:
* * * * * /home/steph/scripts/script-check.sh >> /home/steph/scripts/startup.log
cron job is launched but any idea why startup.log contains the output below?
Mon Mar 4 20:04:01 EST 2013
REDIS: [OFFLINE] Starting Redis Server...[FAILED]
BALLOONS.IO: [OFFLINE] Starting Balloons.IO (with Forever)...[FAILED]
FIREWALL (port 9090): [DENIED] Enabling port 9090...
[FAILED]
and when I manually run script-check.sh linux produces:
Mon Mar 4 20:06:38 EST 2013
REDIS: [ONLINE]
BALLOONS.IO: [OFFLINE] Starting Balloons.IO (with Forever)...[SUCCESS]
FIREWALL (port 9090): [ACCEPT]
Here's script-check.sh content:
echo -ne "$(date)\n";
echo -ne "REDIS: ";
if [ "`redis-cli ping | grep -i pong`" ]
then
echo -ne "[ONLINE]\n";
else
echo -ne "[OFFLINE] Starting Redis Server...";
echo -ne `/etc/init.d/redis_6379 start > /home/steph/stat_redis.log`;
if [ "`redis-cli ping | grep -i pong`" ]
then
echo -ne "[SUCCESS]\n";
else
echo -ne "[FAILED]\n";
fi
fi
echo -ne "BALLOONS.IO: ";
if [ "`forever list | grep -i balloons`" ]
then
echo -ne "[ONLINE]\n";
else
echo -ne "[OFFLINE] Starting Balloons.IO (with Forever)...";
echo -ne `forever start /home/steph/Balloons.IO/balloons.js > /home/steph/stat_balloons.log`;
if [ "`forever list | grep -i balloons`" ]
then
echo -ne "[SUCCESS]\n";
else
echo -ne "[FAILED]\n";
fi
fi
echo -ne "FIREWALL (port 9090): ";
if [ "`iptables-save | grep -- "-A INPUT -p tcp -m tcp --dport 9090 -j ACCEPT"`" ]
then
echo -ne "[ACCEPT]\n";
else
echo -ne "[DENIED] Enabling port 9090...";
echo `iptables -A INPUT -p tcp -m tcp --dport 9090 -j ACCEPT > /home/steph/stat_iptables.log`
if [ "`iptables-save | grep -- "-A INPUT -p tcp -m tcp --dport 9090 -j ACCEPT"`" ]
then
echo -ne "[SUCCESS]\n";
else
echo -ne "[FAILED]\n";
fi
fi