Difference between revisions of "Forever"
From Wiki2
Line 1: | Line 1: | ||
== forever== | == forever== | ||
using a json file is flaky, instead in /root/forgone.sh | |||
#!/bin/sh | |||
forever stopall | |||
sleep 2 | |||
fuser -KILL -k -n tcp 3002 | |||
forever --uid tokauth -a start /home/services/token-auth-server/server.js | |||
sleep 2 | |||
fuser -KILL -k -n tcp 3009 | |||
forever --uid bogged -a start /home/boggedbus/public_html/boggedbus/server/app.js | |||
sleep 2 | |||
fuser -KILL -k -n tcp 1883 # mqtt | |||
fuser -KILL -k -n tcp 3332 # express | |||
fuser -KILL -k -n tcp 3333 # wss | |||
forever --uid geniot -a start /home/services/geniot/lib/index.js | |||
sleep 2 | |||
fuser -KILL -k -n tcp 1642 | |||
forever --uid hellossl -a start /home/services/hello/hello.js | |||
sleep 2 | |||
forever list | |||
and put it in @reboot of /var/spool/cron/crontab/root | |||
@reboot /root/forgone.sh | |||
# m h dom mon dow command | |||
0 2 * * * cd /usr/local/lib/tm/scripts; ./backup.sh | |||
0 3 * * * find /var/backups/s3/*.gz -ctime +5 -type f -print | xargs rm -f | |||
30 3 * * * rsync -avuz --exclude-from=/root/rsync_exclude.txt / root@iotup.stream:/ | |||
30 04 25 Feb,Apr,Jun,Aug,Oct,Dec * /usr/bin/letsencrypt renew >> /var/log/le-renew.log | |||
35 04 25 Feb,Apr,Jun,Aug,Oct,Dec * /bin/systemctl reload nginx | |||
running servers info can be seen in '''/root/appsServers2start.json'''. You stop them and restart them all like this | running servers info can be seen in '''/root/appsServers2start.json'''. You stop them and restart them all like this | ||
Latest revision as of 23:08, 4 January 2017
forever
using a json file is flaky, instead in /root/forgone.sh
#!/bin/sh forever stopall sleep 2 fuser -KILL -k -n tcp 3002 forever --uid tokauth -a start /home/services/token-auth-server/server.js sleep 2 fuser -KILL -k -n tcp 3009 forever --uid bogged -a start /home/boggedbus/public_html/boggedbus/server/app.js sleep 2 fuser -KILL -k -n tcp 1883 # mqtt fuser -KILL -k -n tcp 3332 # express fuser -KILL -k -n tcp 3333 # wss forever --uid geniot -a start /home/services/geniot/lib/index.js sleep 2 fuser -KILL -k -n tcp 1642 forever --uid hellossl -a start /home/services/hello/hello.js sleep 2 forever list
and put it in @reboot of /var/spool/cron/crontab/root
@reboot /root/forgone.sh # m h dom mon dow command 0 2 * * * cd /usr/local/lib/tm/scripts; ./backup.sh 0 3 * * * find /var/backups/s3/*.gz -ctime +5 -type f -print | xargs rm -f 30 3 * * * rsync -avuz --exclude-from=/root/rsync_exclude.txt / root@iotup.stream:/ 30 04 25 Feb,Apr,Jun,Aug,Oct,Dec * /usr/bin/letsencrypt renew >> /var/log/le-renew.log 35 04 25 Feb,Apr,Jun,Aug,Oct,Dec * /bin/systemctl reload nginx
running servers info can be seen in /root/appsServers2start.json. You stop them and restart them all like this
forever stopall forever start ./appsServers2start.json
- /root/.forever/config.json has configuration for forever
- log files are in /root/.forever
/root/appsServers2start.json
[ { //bogged down bus "uid": "bogged", "append": true, "watch": true, "script": "app.js", "sourceDir": "/home/boggedbus/public_html/boggedbus/server" }, { //token-auth-server "uid": "auth", "append": true, "watch": true, "script": "server.js", "sourceDir": "/var/www/token-auth-server" } ]
forever start server2.js forever stop server2.js forever list info: Forever processes running data: uid command script forever pid logfile uptime data: [0] DykF /root/.nvm/v0.10.25/bin/node server2.js 28939 28944 /root/.forever/DykF.log 1:1:2:21.834
ps -Al kill -KILL pid
tail -f /root/.forever/DykF.log
finding port of address already in use
$ sudo netstat -nlp | grep 80 tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN 125004/nginx
or
# sudo lsof -i :25 COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME exim4 2799 Debian-exim 3u IPv4 6645 0t0 TCP localhost:smtp (LISTEN) exim4 2799 Debian-exim 4u IPv6 6646 0t0 TCP localhost:smtp (LISTEN)