Fix shutdown behaviour
This commit is contained in:
parent
3a90e80b87
commit
b46300a32d
3 changed files with 2 additions and 32 deletions
|
@ -22,10 +22,6 @@ MCSD_SAFEMODE=false
|
||||||
# Removes all log files on startup (restarts are not affected)
|
# Removes all log files on startup (restarts are not affected)
|
||||||
MCSD_CLEAN_LOGS=true
|
MCSD_CLEAN_LOGS=true
|
||||||
|
|
||||||
# AUTO_RESTART
|
|
||||||
## Restarts the server automatically if it exits
|
|
||||||
MCSD_AUTO_RESTART=true
|
|
||||||
|
|
||||||
#################
|
#################
|
||||||
# Memory limits #
|
# Memory limits #
|
||||||
#################
|
#################
|
||||||
|
|
|
@ -4,7 +4,7 @@ services:
|
||||||
mcsd:
|
mcsd:
|
||||||
build: .
|
build: .
|
||||||
container_name: mcsd
|
container_name: mcsd
|
||||||
restart: no
|
restart: unless-stopped
|
||||||
stop_grace_period: 120s
|
stop_grace_period: 120s
|
||||||
volumes:
|
volumes:
|
||||||
- ./server:/data
|
- ./server:/data
|
||||||
|
|
|
@ -168,14 +168,7 @@ function run() {
|
||||||
cd /data||exit 69
|
cd /data||exit 69
|
||||||
# We want to use ${ARGS} without using parenthesis
|
# We want to use ${ARGS} without using parenthesis
|
||||||
# shellcheck disable=SC2086
|
# shellcheck disable=SC2086
|
||||||
"/usr/lib/jvm/java-${MCSD_JAVA_VERSION}-openjdk/bin/java" ${FLAGS} -jar "/data/server.jar" ${ARGS} &
|
exec "/usr/lib/jvm/java-${MCSD_JAVA_VERSION}-openjdk/bin/java" ${FLAGS} -jar "/data/server.jar" ${ARGS} &
|
||||||
# Set server pid
|
|
||||||
export "CHILDPID=${!}"
|
|
||||||
# Setup trap
|
|
||||||
trap kill_server SIGTERM
|
|
||||||
trap kill_server SIGINT
|
|
||||||
# Wait for server to end
|
|
||||||
wait
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# Need I say more?
|
# Need I say more?
|
||||||
|
@ -187,26 +180,7 @@ function main() {
|
||||||
clean_logs
|
clean_logs
|
||||||
compile_args
|
compile_args
|
||||||
compile_flags
|
compile_flags
|
||||||
# Run server once
|
|
||||||
run
|
run
|
||||||
# Restart server if enabled
|
|
||||||
if [ "${SHUTDOWN}" == "true" ]; then
|
|
||||||
echo ":: Ending execution (SHUTDOWN=true)"
|
|
||||||
exit 0
|
|
||||||
fi
|
|
||||||
case "${MCSD_AUTO_RESTART}" in
|
|
||||||
"true")
|
|
||||||
echo ":: Restarting server"
|
|
||||||
run
|
|
||||||
;;
|
|
||||||
"false")
|
|
||||||
echo ":: Ending execution (MCSD_AUTO_RESTART=false)"
|
|
||||||
exit 0
|
|
||||||
;;
|
|
||||||
*)
|
|
||||||
internal_error "\$MCSD_AUTO_RESTART has invalid value"
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
}
|
}
|
||||||
|
|
||||||
main
|
main
|
||||||
|
|
Loading…
Reference in a new issue