mirror of
https://github.com/eliasstepanik/ark-ac-server-tools.git
synced 2026-01-27 16:58:27 +00:00
Fix a couple of issues with stopping
This commit is contained in:
parent
33851a849b
commit
a0f464d72c
@ -594,7 +594,7 @@ function getServerPID(){
|
|||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ -z "$arkopt_clusterid" ]; then
|
if [[ -z "$arkopt_clusterid" || -f "${arkserverroot}/${arkoldautorestartfile}" ]]; then
|
||||||
ps -ef | grep "$arkserverroot/$arkserverexec" | grep -v grep | awk '{print $2}'
|
ps -ef | grep "$arkserverroot/$arkserverexec" | grep -v grep | awk '{print $2}'
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
@ -739,8 +739,8 @@ doRun() {
|
|||||||
# $$ returns the main process, $BASHPID returns the current process
|
# $$ returns the main process, $BASHPID returns the current process
|
||||||
echo "$BASHPID" >"${arkserverroot}/${arkmanagerpidfile}"
|
echo "$BASHPID" >"${arkserverroot}/${arkmanagerpidfile}"
|
||||||
|
|
||||||
if [ -f "${arkserverroot}/.ark-update.lock" ]; then
|
if [ -f "${arkserverroot}/${arkupdatelockfile}" ]; then
|
||||||
local updatepid="$(<"${arkserverroot}/.ark-update.lock")"
|
local updatepid="$(<"${arkserverroot}/${arkupdatelockfile}")"
|
||||||
if kill -0 "$updatepid" >/dev/null 2>&1; then
|
if kill -0 "$updatepid" >/dev/null 2>&1; then
|
||||||
echo "An update is currently in progress. Start aborted"
|
echo "An update is currently in progress. Start aborted"
|
||||||
return 1
|
return 1
|
||||||
@ -957,8 +957,8 @@ doRun() {
|
|||||||
doStart() {
|
doStart() {
|
||||||
touch "${arkserverroot}/.startAfterUpdate-${instance}"
|
touch "${arkserverroot}/.startAfterUpdate-${instance}"
|
||||||
|
|
||||||
if [ -f "${arkserverroot}/.ark-update.lock" ]; then
|
if [ -f "${arkserverroot}/${arkupdatelockfile}" ]; then
|
||||||
local updatepid="$(<"${arkserverroot}/.ark-update.lock")"
|
local updatepid="$(<"${arkserverroot}/${arkupdatelockfile}")"
|
||||||
if kill -0 "$updatepid" >/dev/null 2>&1; then
|
if kill -0 "$updatepid" >/dev/null 2>&1; then
|
||||||
echo "An update is currently in progress. Start aborted"
|
echo "An update is currently in progress. Start aborted"
|
||||||
echo "`timestamp`: Start aborted due to running update - pid: $updatepid" >>"$logdir/$arkserverLog"
|
echo "`timestamp`: Start aborted due to running update - pid: $updatepid" >>"$logdir/$arkserverLog"
|
||||||
@ -1053,6 +1053,7 @@ doStop() {
|
|||||||
echo "Stopping server..."
|
echo "Stopping server..."
|
||||||
echo "`timestamp`: stopping; reason: $stopreason" >> "$logdir/$arkmanagerLog"
|
echo "`timestamp`: stopping; reason: $stopreason" >> "$logdir/$arkmanagerLog"
|
||||||
rm -f "$arkserverroot/$arkautorestartfile"
|
rm -f "$arkserverroot/$arkautorestartfile"
|
||||||
|
rm -f "$arkserverroot/$arkoldautorestartfile"
|
||||||
# kill the server with the PID
|
# kill the server with the PID
|
||||||
PID=`getServerPID`
|
PID=`getServerPID`
|
||||||
kill -INT $PID
|
kill -INT $PID
|
||||||
@ -1139,11 +1140,11 @@ doInstall() {
|
|||||||
# Cancels a pending shutdown
|
# Cancels a pending shutdown
|
||||||
#
|
#
|
||||||
doCancelShutdown(){
|
doCancelShutdown(){
|
||||||
if [ -f "${arkserverroot}/.ark-warn.lock" ]; then
|
if [ -f "${arkserverroot}/${arkwarnlockfile}" ]; then
|
||||||
local lockpid="$(<"${arkserverroot}/.ark-warn.lock")"
|
local lockpid="$(<"${arkserverroot}/${arkwarnlockfile}")"
|
||||||
if [ -n "$lockpid" ]; then
|
if [ -n "$lockpid" ]; then
|
||||||
kill "$lockpid"
|
kill "$lockpid"
|
||||||
rm -f "${arkserverroot}/.ark-warn.lock"
|
rm -f "${arkserverroot}/${arkwarnlockfile}"
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
@ -1295,21 +1296,21 @@ doWarn(){
|
|||||||
cd "$arkserverroot"
|
cd "$arkserverroot"
|
||||||
|
|
||||||
(
|
(
|
||||||
echo "$$" >"${arkserverroot}/.ark-warn.lock.$$" 2>/dev/null
|
echo "$$" >"${arkserverroot}/${arkwarnlockfile}.${BASHPID}" 2>/dev/null
|
||||||
while true; do
|
while true; do
|
||||||
if ! ln "${arkserverroot}/.ark-warn.lock.$$" "${arkserverroot}/.ark-warn.lock" 2>/dev/null; then
|
if ! ln "${arkserverroot}/${arkwarnlockfile}.${BASHPID}" "${arkserverroot}/${arkwarnlockfile}" 2>/dev/null; then
|
||||||
local lockpid="$(<"${arkserverroot}/.ark-warn.lock")"
|
local lockpid="$(<"${arkserverroot}/${arkwarnlockfile}")"
|
||||||
if [ -n "$lockpid" ] && [ "$lockpid" != "$$" ] && kill -0 "$lockpid" 2>/dev/null; then
|
if [ -n "$lockpid" ] && [ "$lockpid" != "$$" ] && kill -0 "$lockpid" 2>/dev/null; then
|
||||||
echo "Shutdown warning already in progress (PID: $lockpid)"
|
echo "Shutdown warning already in progress (PID: $lockpid)"
|
||||||
rm -f "${arkserverroot}/.ark-warn.lock.$$" 2>/dev/null
|
rm -f "${arkserverroot}/${arkwarnlockfile}.${BASHPID}" 2>/dev/null
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
rm -f "${arkserverroot}/.ark-warn.lock"
|
rm -f "${arkserverroot}/${arkwarnlockfile}"
|
||||||
else
|
else
|
||||||
break
|
break
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
rm -f "${arkserverroot}/.ark-warn.lock.$$"
|
rm -f "${arkserverroot}/${arkwarnlockfile}.${BASHPID}"
|
||||||
|
|
||||||
update_cancelled(){
|
update_cancelled(){
|
||||||
if [ -n "$msgUpdateCancelled" ]; then
|
if [ -n "$msgUpdateCancelled" ]; then
|
||||||
@ -1340,7 +1341,7 @@ doWarn(){
|
|||||||
for warninterval in "${warnintervals[@]}"; do
|
for warninterval in "${warnintervals[@]}"; do
|
||||||
if [ "`getServerPID`" != "$pid" ]; then
|
if [ "`getServerPID`" != "$pid" ]; then
|
||||||
echo "Server has stopped. Aborting $1"
|
echo "Server has stopped. Aborting $1"
|
||||||
rm -f "${arkserverroot}/.ark-warn.lock"
|
rm -f "${arkserverroot}/${arkwarnlockfile}"
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
if (( warnminutes >= warninterval )); then
|
if (( warnminutes >= warninterval )); then
|
||||||
@ -1355,7 +1356,7 @@ doWarn(){
|
|||||||
return 0
|
return 0
|
||||||
elif (( (numplayers + 0) == 0 )); then
|
elif (( (numplayers + 0) == 0 )); then
|
||||||
doBroadcastWithEcho "Nobody is connected. Shutting down immediately"
|
doBroadcastWithEcho "Nobody is connected. Shutting down immediately"
|
||||||
rm -f "${arkserverroot}/.ark-warn.lock"
|
rm -f "${arkserverroot}/${arkwarnlockfile}"
|
||||||
return 0
|
return 0
|
||||||
fi
|
fi
|
||||||
if isUpdateCancelRequested; then
|
if isUpdateCancelRequested; then
|
||||||
@ -1379,7 +1380,7 @@ doWarn(){
|
|||||||
sleeppid=$!
|
sleeppid=$!
|
||||||
if [ "`getServerPID`" != "$pid" ]; then
|
if [ "`getServerPID`" != "$pid" ]; then
|
||||||
echo "Server has stopped. Aborting update"
|
echo "Server has stopped. Aborting update"
|
||||||
rm -f "${arkserverroot}/.ark-warn.lock"
|
rm -f "${arkserverroot}/${arkwarnlockfile}"
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
printWarnMessage "$1" "$2" "seconds" "$warnseconds"
|
printWarnMessage "$1" "$2" "seconds" "$warnseconds"
|
||||||
@ -1391,7 +1392,7 @@ doWarn(){
|
|||||||
return 0
|
return 0
|
||||||
elif (( (numplayers + 0) == 0 )); then
|
elif (( (numplayers + 0) == 0 )); then
|
||||||
doBroadcastWithEcho "Nobody is connected. Shutting down immediately"
|
doBroadcastWithEcho "Nobody is connected. Shutting down immediately"
|
||||||
rm -f "${arkserverroot}/.ark-warn.lock"
|
rm -f "${arkserverroot}/${arkwarnlockfile}"
|
||||||
return 0
|
return 0
|
||||||
fi
|
fi
|
||||||
if isUpdateCancelRequested; then
|
if isUpdateCancelRequested; then
|
||||||
@ -1404,7 +1405,7 @@ doWarn(){
|
|||||||
done
|
done
|
||||||
fi
|
fi
|
||||||
|
|
||||||
rm -f "${arkserverroot}/.ark-warn.lock"
|
rm -f "${arkserverroot}/${arkwarnlockfile}"
|
||||||
|
|
||||||
if [ "`getServerPID`" != "$pid" ]; then
|
if [ "`getServerPID`" != "$pid" ]; then
|
||||||
echo "Server has stopped. Aborting $1"
|
echo "Server has stopped. Aborting $1"
|
||||||
@ -1459,23 +1460,23 @@ doUpdate() {
|
|||||||
serverWasAlive=1
|
serverWasAlive=1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo "$$" >"${arkserverroot}/.ark-update.lock.$$" 2>/dev/null
|
echo "$$" >"${arkserverroot}/${arkupdatelockfile}.${BASHPID}" 2>/dev/null
|
||||||
while true; do
|
while true; do
|
||||||
if ! ln "${arkserverroot}/.ark-update.lock.$$" "${arkserverroot}/.ark-update.lock" 2>/dev/null; then
|
if ! ln "${arkserverroot}/${arkupdatelockfile}.${BASHPID}" "${arkserverroot}/${arkupdatelockfile}" 2>/dev/null; then
|
||||||
local lockpid="$(<"${arkserverroot}/.ark-update.lock")"
|
local lockpid="$(<"${arkserverroot}/${arkupdatelockfile}")"
|
||||||
if [ -n "$lockpid" ] && [ "$lockpid" != "$$" ] && kill -0 "$lockpid" 2>/dev/null; then
|
if [ -n "$lockpid" ] && [ "$lockpid" != "$$" ] && kill -0 "$lockpid" 2>/dev/null; then
|
||||||
echo "Update already in progress (PID: $lockpid)"
|
echo "Update already in progress (PID: $lockpid)"
|
||||||
rm -f "${arkserverroot}/.ark-update.lock.$$" 2>/dev/null
|
rm -f "${arkserverroot}/${arkupdatelockfile}.${BASHPID}" 2>/dev/null
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
rm -f "${arkserverroot}/.ark-update.lock"
|
rm -f "${arkserverroot}/${arkupdatelockfile}"
|
||||||
else
|
else
|
||||||
break
|
break
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
rm -f "${arkserverroot}/.ark-update.lock.$$"
|
rm -f "${arkserverroot}/${arkupdatelockfile}.${BASHPID}"
|
||||||
|
|
||||||
echo "`timestamp`: checking for update; PID: $$"
|
echo "`timestamp`: checking for update; PID: ${BASHPID}"
|
||||||
|
|
||||||
if [ -n "$modupdate" ]; then
|
if [ -n "$modupdate" ]; then
|
||||||
if [ -z "$nodownload" ]; then
|
if [ -z "$nodownload" ]; then
|
||||||
@ -1632,7 +1633,7 @@ doUpdate() {
|
|||||||
echo "`timestamp`: No update needed." >> "$logdir/update.log"
|
echo "`timestamp`: No update needed." >> "$logdir/update.log"
|
||||||
fi;
|
fi;
|
||||||
|
|
||||||
rm -f "${arkserverroot}/.ark-update.lock"
|
rm -f "${arkserverroot}/${arkupdatelockfile}"
|
||||||
|
|
||||||
if ! isTheServerRunning; then
|
if ! isTheServerRunning; then
|
||||||
# we restart the server only if it was started before the update
|
# we restart the server only if it was started before the update
|
||||||
@ -2485,9 +2486,13 @@ useConfig() {
|
|||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
arkautorestartfile="${arkautorestartfile:-ShooterGame/Saved/.autorestart-${1}}"
|
arkautorestartfile="${arkautorestartfile:-ShooterGame/Saved/.autorestart-${1}}"
|
||||||
|
arkoldautorestartfile="ShooterGame/Saved/.autorestart"
|
||||||
arkserverpidfile="${arkserverpidfile:-ShooterGame/Saved/.arkserver-${1}.pid}"
|
arkserverpidfile="${arkserverpidfile:-ShooterGame/Saved/.arkserver-${1}.pid}"
|
||||||
arkserveroldpidfile="ShooterGame/Saved/.arkserver.pid"
|
arkserveroldpidfile="ShooterGame/Saved/.arkserver.pid"
|
||||||
arkmanagerpidfile="${arkmanagerpidfile:-ShooterGame/Saved/.arkmanager-${1}.pid}"
|
arkmanagerpidfile="${arkmanagerpidfile:-ShooterGame/Saved/.arkmanager-${1}.pid}"
|
||||||
|
arkwarnlockfile="${arkwarnlockfile:-ShooterGame/Saved/.ark-warn-${instance}.lock}"
|
||||||
|
# This is linked to the directory, not to the instance
|
||||||
|
arkupdatelockfile="${arkupdatelockfile:-ShooterGame/Saved/.ark-update.lock}"
|
||||||
}
|
}
|
||||||
|
|
||||||
showUsage() {
|
showUsage() {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user