From 7efbbd3fdf6a35da09ee10a314e67accfa482ea6 Mon Sep 17 00:00:00 2001 From: Ben Peddell Date: Fri, 26 Aug 2016 17:25:56 +1000 Subject: [PATCH] Add arkPriorityBoost --- tools/arkmanager | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/tools/arkmanager b/tools/arkmanager index 281333d..8ef7826 100755 --- a/tools/arkmanager +++ b/tools/arkmanager @@ -666,6 +666,12 @@ doRun() { fi fi + if [ " $* " = *" --wait "* ]; then + # This requires bash 4+ + # $$ returns the main process, $BASHPID returns the current process + kill -STOP $BASHPID # wait for caller to renice us + fi + arkserveropts="$serverMap" while read varname; do @@ -893,7 +899,20 @@ doStart() { tput sc echo "The server is starting..." - doRun >"$logdir/$arkserverLog" 2>&1 & # output of this command is logged + local pid=$! + if [ -n "$arkPriorityBoost" ]; then + doRun --wait >"$logdir/$arkserverLog" 2>&1 & # output of this command is logged + local pid="$!" + + # Wait for monitor process to suspend itself + wait + + echo "Boosting priority of ark server" + sudo renice -n "$arkPriorityBoost" "$pid" + kill -CONT "$pid" + else + doRun >"$logdir/$arkserverLog" 2>&1 & # output of this command is logged + fi echo "`timestamp`: start" >> "$logdir/$arkmanagerLog" tput rc; tput ed; echo "The server is now running, and should be up within 10 minutes"