X-Git-Url: https://git.ucc.asn.au/?a=blobdiff_plain;f=server%2Frun.sh;h=1563d2e4de4141a61b8a3e98c958d8d96eca0d8c;hb=417b7e54a0123ffae25a62ce99288abaccdde805;hp=c2bd504f95067bf1df36d47c75566ba7dd18c43b;hpb=01ea4e1cddca0bbf359739a1fefffdccada60481;p=matches%2FMCTX3420.git diff --git a/server/run.sh b/server/run.sh index c2bd504..1563d2e 100755 --- a/server/run.sh +++ b/server/run.sh @@ -1,15 +1,18 @@ #!/bin/bash -# Use this to quickly test run the server in valgrind -#spawn-fcgi -p9005 -n ./valgrind.sh -# Use this to run the server normally -#./stream & + +# Check existence of program +if [ ! -e "server" ]; then + (echo "Rebuild server.") 1>&2; + exit 1 +fi + if [[ "$(uname -m)" != *arm* ]]; then echo Not running on the BBB # Use this to quickly test run the server in valgrind spawn-fcgi -p9005 -n ./valgrind.sh # Use this to run the server normally - #./stream & + #spawn-fcgi -p9005 -n ./server exit 0 fi @@ -19,12 +22,6 @@ if [ "$(whoami)" != "root" ]; then exit 1 fi -# Check existence of program -if [ ! -e "server" ]; then - (echo "Rebuild server.") 1>&2; - exit 1 -fi - # Rotate the logs echo Rotating the system logs logrotate -f /etc/logrotate.d/mctxserv.conf @@ -86,8 +83,11 @@ echo "Parameters are: $parameters" # Run the program with parameters # TODO: Can tell spawn-fcgi to run the program as an unprivelaged user? # But first will have to work out how to set PWM/GPIO as unprivelaged user +# NOTE: Having the program automatically restart itself after a *FATAL ERROR* doesn't seem like such a good idea now +# (Some things that call Fatal happen under circumstances where they will just keep calling Fatal every time the program starts) +# Change the number of fails to 1 for now. We can potentially use different error codes for different types of errors, but that seems overkill. fails=0 -while [ $fails -lt 10 ]; do +while [ $fails -lt 1 ]; do spawn-fcgi -p9005 -n -- ./server $parameters error=$? if [ "$error" == "0" ]; then