#!/bin/sh

echo "***** The VP process is not running *****"

# MOD: 29-Sep-2020
# New server.
# forever wasn't being found but was working from Terminal so got the current path from Terminal and used this instead. 
export PATH=$PATH:/root/.nvm/versions/node/v9.11.2/bin:/usr/local/cpanel/3rdparty/lib/path-bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/opt/cpanel/composer/bin:/usr/local/lib:/root/bin
#export PATH=$PATH:/usr/local/jdk/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/opt/cpanel/composer/bin:/usr/local/bin:/usr/X11R6/bin:/root/bin

# From Gary as was getting errors.
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib

# Real.

# MOD: 29-Sep-2020
# New server.
cd /home/VP/Step7 2>&1
#//cd /root/public_html/garytest/Zhang/step7safe 2>&1
#cd /root/public_html/garytest/Zhang/step7safeEval 2>&1

#echo "----------DIR START";
#ls  2>&1
#echo "----------DIR END";
#echo $LD_LIBRARY_PATH;
#echo "-----------------";

echo "***** Listing processes running before stopping/restarting *****"
forever list 2>&1
echo "***** Stopping existing script in case running but not responding *****"
forever stop 0 2>&1
forever stop 0 2>&1
forever stop 0 2>&1
forever stop 0 2>&1
forever stop 0 2>&1
echo "***** Starting process *****"
forever start serverStep7safe.js 2>&1

# Test.
#cd /home/viziserv/subdomains/vp/public_html/garytest/Zhang/server8088 2>&1
#echo "***** Stopping existing script in case running but not responding *****"
#forever stop 1 2>&1
#echo "***** Starting process *****"
#forever start serverStep7safe8088.js 2>&1

echo "***** Listing processes running after stopping/restarting *****"
echo "***** Doesn't list the new process, maybe it's not running immediately after the 'start' (it did used to on old server) *****"
forever list 2>&1
