Keeping VRS online 24/7
Keeping VRS online 24/7
Hi All, currently having an issue the only way I can keep my VRS server on is by keeping a PuTTY client connected to it whenever I want it to access the VRS page. Is there any way I can run the VRS 100% dedicated on my Raspberry Pi B?
Thanks!
Thanks!
Re: Keeping VRS online 24/7
This has come up before - Linux has a variety of ways of keeping a program running in the background after the shell is closed. You could try some of the suggestions here:
viewtopic.php?f=1&t=1280&p=7245
viewtopic.php?f=1&t=1280&p=7245
Re: Keeping VRS online 24/7
Had a similar issue myself and now succesfully running Mono under Screen works for me on centos 7, allows you detached and open other putty windows along with close them to run in the background.
Click Here For My VRS Install
360 Radar Contributor |Freedar Contributor| Opensky Network Contributor | ADSBhub Contributor
360 Radar Contributor |Freedar Contributor| Opensky Network Contributor | ADSBhub Contributor
Re: Keeping VRS online 24/7
for some reason screen wouldn't work so I opted for tmux and works a charm
Re: Keeping VRS online 24/7
Mine running on W7 and the work perfect. 







Re: Keeping VRS online 24/7
Hey all,
I run VRS from this little script I made -- it's moderately-robust, but if you have a really weird setup, it might not work for you.
You can just call this something like "run_vrs.sh", and then invoke it as:
Here's the script. Make sure you edit "VRSPATH", "LOG" and "MONOBIN" if they differ for you.
VRSPATH is where the VirtualRadar.exe lives.
Since this script redirects all output into a log file, it should survive you logging out.
You can try invoking this with "nohup" before the script name, but that may or may not matter.
Installing 'screen' or 'tmux' and running it from within that is probably a better bet (but will not auto-start at boot).
I can see about editing this script so that it's safe to run from rc.local or even from cron, if people are interested enough.
-Taner
I run VRS from this little script I made -- it's moderately-robust, but if you have a really weird setup, it might not work for you.
You can just call this something like "run_vrs.sh", and then invoke it as:
Code: Select all
./run_vrs.sh &
VRSPATH is where the VirtualRadar.exe lives.
Code: Select all
#!/bin/bash
VRSPATH="/home/adsb/vrs"
LOG="/home/adsb/logs/VRS.log"
MONOBIN="/usr/bin/mono"
VRSEXEC="$MONOBIN VirtualRadar.exe -nogui"
SLEEPTIME=2
FAIL_SLEEP=60
MIN_RUN_TIME=30
touch $LOG
if [ ! -f $LOG ]; then
echo "Something Bad Happening - can't find/use $LOG for logging, please fix"
exit -1
fi
if [ ! -d $VRSPATH ]; then
echo "Sorry, $VRSPATH doesn't exist or isn't a directory, bailing out..."
exit -1
fi
if [ ! -x $MONOBIN ]; then
echo "Sorry, mono at location $MONOBIN doesn't exist or isn't executable, bailing out..."
exit -1
fi
while true; do
echo "`date` :: Starting VRS launch loop..." >> $LOG 2>&1
VRS_START=`date +%s`
cd $VRSPATH
echo "`date` :: Starting [$VRSEXEC]..." >> $LOG 2>&1
$VRSEXEC >> $LOG 2>&1
RV=$?
VRS_END=`date +%s`
VRS_TIME=$(($VRS_END-$VRS_START))
echo "`date` :: VRS exited with [$RV]. Sleeping $SLEEPTIME seconds..." >> $LOG 2>&1
sleep $SLEEPTIME
if [ $VRS_TIME -lt $MIN_RUN_TIME ]; then
echo "`date` :: Exited quickly (less than $MIN_RUN_TIME seconds), waiting a little more ($FAIL_SLEEP sec)..." >> $LOG 2>&1
sleep $FAIL_SLEEP
fi
done
You can try invoking this with "nohup" before the script name, but that may or may not matter.
Installing 'screen' or 'tmux' and running it from within that is probably a better bet (but will not auto-start at boot).
I can see about editing this script so that it's safe to run from rc.local or even from cron, if people are interested enough.
-Taner
Re: Keeping VRS online 24/7
Ok, I added the ability for this to just get run from cron, perhaps every 5 minutes, and it will exit silently if it's already running. You'd want to add a line like this to whatever user's crontab you run this as (run 'crontab -e' as that user):
I tried to make it fairly-robust and fairly-foolproof, but I'm sure you can break it if you try 
PLEASE make sure you edit the first three variables to suit your environment (VRSPATH, LOGDIR, MONOBIN). You may also need/want to edit the "VRSEXEC" line if you use different parameters.
Code: Select all
*/5 * * * * /home/adsb/cron/run_vrs.sh

PLEASE make sure you edit the first three variables to suit your environment (VRSPATH, LOGDIR, MONOBIN). You may also need/want to edit the "VRSEXEC" line if you use different parameters.
Code: Select all
#!/bin/bash
VRSPATH="/home/adsb/vrs"
LOGDIR="/home/adsb/cron/data"
MONOBIN="/usr/bin/mono"
LOG="${LOGDIR}/VRS.log"
PIDFILE="${LOGDIR}/run_vrs.pid"
VRSEXEC="$MONOBIN VirtualRadar.exe -nogui"
SLEEPTIME=2
FAIL_SLEEP=60
MIN_RUN_TIME=30
T="/usr/bin/tee -a $LOG"
PID=$$
if [ ! -d $LOGDIR ]; then
if [ -e $LOGDIR ]; then
echo "FATAL - $LOGDIR exists but is not a directory"
exit -1
fi
echo "$LOGDIR doesn't seem to exist, attempting to create...."
mkdir -p $LOGDIR
RV=$?
if [ $RV -ne 0 ]; then
echo "FATAL - couldn't create directory $LOGDIR (error $RV)"
exit -1
fi
fi
# Can we poke the log file?
touch $LOG
if [ ! -f $LOG ]; then
echo "Something Bad Happening - can't find/use $LOG for logging, please fix"
exit -1
fi
# *** At this point, the logfile should work, so use it when appropriate (non-fatal)
if [ -f $PIDFILE ]; then
OLD_PID=`cat $PIDFILE`
if [ x"$OLD_PID" == "x" ]; then
echo "PID file $PIDFILE is empty - skipping check..." >> $LOG
else
KILL=`kill -0 $OLD_PID 2>&1`
RV=$?
if [ $RV -eq 0 ]; then
# Already running, exit quietly
exit
fi
echo "`date` :: PID $OLD_PID from pidfile isn't running..." >> $LOG 2>&1
fi
fi
echo $PID > $PIDFILE
# Last sanity check, in case it got started by hand...
PS_SCAN=`ps -ef | grep VirtualRadar.exe | grep mono | grep -v grep`
RV=$?
if [ $RV -ne 1 ]; then
# Oops, we found something running!
echo "Weirdness - found something running:" | $T
echo $PS_SCAN | $T
echo "Aborting..." | $T
exit -1
fi
# Sanity here
touch $PIDFILE
if [ ! -f $PIDFILE ]; then
echo "Something Bad Happening - can't create PID file $PIDFILE, please fix" | $T
exit -1
fi
if [ ! -d $VRSPATH ]; then
echo "Sorry, $VRSPATH doesn't exist or isn't a directory, bailing out..." | $T
exit -1
fi
if [ ! -x $MONOBIN ]; then
echo "Sorry, mono at location $MONOBIN doesn't exist or isn't executable, bailing out..." | $T
exit -1
fi
while true; do
echo "`date` :: Starting VRS launch loop..." >> $LOG 2>&1
VRS_START=`date +%s`
cd $VRSPATH
echo "`date` :: Starting [$VRSEXEC]..." >> $LOG 2>&1
$VRSEXEC 2>&1 >> $LOG
RV=$?
VRS_END=`date +%s`
VRS_TIME=$(($VRS_END-$VRS_START))
echo "`date` :: VRS exited with [$RV]. Sleeping $SLEEPTIME seconds..." >> $LOG 2>&1
sleep $SLEEPTIME
if [ $VRS_TIME -lt $MIN_RUN_TIME ]; then
echo "`date` :: Exited quickly (less than $MIN_RUN_TIME seconds), waiting a little more ($FAIL_SLEEP sec)..." >> $LOG 2>&1
sleep $FAIL_SLEEP
fi
done
Re: Keeping VRS online 24/7
You can also have Linux start VRS on boot using the init.d and a daemon.
This link shows a step by step process for starting VRS on boot. It will also allow you to start and stop VRS using `sudo systemctl start virtualradar` syntax.
https://steamforge.net/wiki/index.php/H ... ar_on_Boot
This link shows a step by step process for starting VRS on boot. It will also allow you to start and stop VRS using `sudo systemctl start virtualradar` syntax.
https://steamforge.net/wiki/index.php/H ... ar_on_Boot
Re: Keeping VRS online 24/7
min run on a Virtual Win7 24/7 (if the Internet not crash when it start to Rain)! (If someone want to share...
)






