Move start delay to doStart; add pre-start script

This commit is contained in:
Ben Peddell 2019-01-24 14:57:13 +10:00
parent f1a90f5c27
commit abd6c2f02a
3 changed files with 27 additions and 16 deletions

View File

@ -1230,6 +1230,16 @@ doStart() {
if [ -n "$serverpid" ] && kill -0 "$serverpid"; then
logprint "Start aborted due to server already running - pid: $serverpid"
else
local prestart="${configfile%.cfg}.start"
if [ -n "${arkPreStart}" ]; then
prestart="${arkPreStart}"
fi
if [[ -n "${prestart}" && -f "${prestart}" ]]; then
"${prestart}" "$@"
fi
if [ "$arkAutoUpdateOnStart" == "true" ]; then
if ! [[ " $* " =~ " --noautoupdate " ]]; then
logprint "Checking for updates before starting"
@ -1277,6 +1287,20 @@ doStart() {
fi
tput rc; tput ed;
logprint "The server is now running, and should be up within 10 minutes"
if [[ -n "$arkStartDelay" || -n "$defaultinstance_max" ]]; then
local delay="${arkStartDelay:-${defaultinstance_max}}"
if (( "${#instances[@]}" > 1 )); then
echo -n "Waiting up to ${delay} seconds before starting next instance "
while (( delay > 0 )); do
echo -n "."
if isTheServerOnline; then
break
fi
(( delay-- ))
done
echo
fi
fi
fi
}
@ -3434,20 +3458,6 @@ main(){
;;
start)
doStart "${options[@]}"
if [[ ${#instances[@]} > 1 ]]; then
COUNTER=0
if [ -z "$defaultinstance_max" ]; then
defaultinstance_max=0
fi
while [ $COUNTER -lt $defaultinstance_max ]; do
echo -ne "$NORMAL Waiting up to $RED$((defaultinstance_max-COUNTER))$NORMAL seconds before starting next instance."\\r
let COUNTER=COUNTER+1
if isTheServerOnline ;then
break
fi
sleep 1s
done
fi
;;
stop)
doStop shutdown "${options[@]}"

View File

@ -18,6 +18,8 @@ arkwarnminutes="60" # number of
arkautorestartfile="ShooterGame/Saved/.autorestart" # path to autorestart file
arkAutoUpdateOnStart="false" # set this to true if you want to always update before startup
arkBackupPreUpdate="false" # set this to true if you want to perform a backup before updating
#arkStartDelay=20 # set this to change the maximum delay between server starts - 0 or unser for no delay, will continue immediately when server is up
#defaultinstance_max=20 # Same as above, for v1.6.43 compatibility
#arkStagingDir="/home/steam/ARK-Staging" # Uncomment to enable updates to be fully downloaded before restarting the server (reduces downtime while updating)
# Options to automatically remove old backups to keep backup size in check
@ -85,4 +87,3 @@ mod_branch=Windows
#configfile_ark1="/path/to/config/file"
defaultinstance="main"
defaultinstance_max=20 #The start @all command will wait until this many seconds before starting next instance. If server becomes available it instantly moves to next instance. Enter value of 0 to have no delay.

View File

@ -25,4 +25,4 @@ ark_MaxPlayers="70"
# ARK server options - i.e. for -optname=val, use arkopt_optname=val
#arkopt_StructureDestructionTag=DestroySwampSnowStructures
#arkPreStart="/etc/arkmanager/instances/instance.start" # Set this to override the start script; defaults to config file name with .cfg replaced by .start