diff options
author | Gordian Edenhofer | 2021-10-20 22:15:40 +0200 |
---|---|---|
committer | Gordian Edenhofer | 2021-10-20 22:27:13 +0200 |
commit | 78fe0aa9d8400a31fe4a6f9009466f500a7379cc (patch) | |
tree | 41bfad4f5727eb0b525e26beaf07c86b6f901a02 | |
parent | 94d319e9c95f7fd5f5bde33297392cdd50978f83 (diff) | |
download | aur-78fe0aa9d8400a31fe4a6f9009466f500a7379cc.tar.gz |
upgpkg: minecraft-server 1.17.1-3
Print the output of the server to the terminal if startup fails.
Evaluate a failure during startup by constantly inspecting the output of
the server for the first 15 seconds during startup.
Relates to #13 .
upgpkg: cuberite 1.12.2c1_afe07fe-1
upgpkg: cuberite-bin 1.12.2b284-3
upgpkg: papermc 1.17.1+b341-1
upgpkg: spigot 1.17.1+b131-4
-rw-r--r-- | .SRCINFO | 14 | ||||
-rw-r--r-- | PKGBUILD | 4 | ||||
-rwxr-xr-x | papermc.sh | 56 |
3 files changed, 57 insertions, 17 deletions
@@ -1,7 +1,7 @@ pkgbase = papermc pkgdesc = Next generation of Minecraft server, compatible with Spigot plugins and offering uncompromising performance - pkgver = 1.17.1+b243 - pkgrel = 3 + pkgver = 1.17.1+b341 + pkgrel = 1 url = https://papermc.io/ install = papermc.install arch = any @@ -15,9 +15,9 @@ pkgbase = papermc optdepends = tar: needed in order to create world backups optdepends = netcat: required in order to suspend an idle server conflicts = papermc-git - noextract = papermc.1.17.1+b243.jar + noextract = papermc.1.17.1+b341.jar backup = etc/conf.d/papermc - source = papermc.1.17.1+b243.jar::https://papermc.io/api/v2/projects/paper/versions/1.17.1/builds/243/downloads/paper-1.17.1-243.jar + source = papermc.1.17.1+b341.jar::https://papermc.io/api/v2/projects/paper/versions/1.17.1/builds/341/downloads/paper-1.17.1-341.jar source = papermc-backup.service source = papermc-backup.timer source = papermc.service @@ -25,13 +25,13 @@ pkgbase = papermc source = papermc.sh source = papermc.tmpfiles source = papermc.sysusers - source = LICENSE_1.17.1+b243.md::https://raw.githubusercontent.com/PaperMC/Paper/f25facb/LICENSE.md - sha512sums = f40e1448c96e786317df5db374832ce716245cf30235012f45faf1f074132445beb4f6a69d8cc5aa87ba17c340b9848aba4fa13bbf553bd6cdfec12aa6d3d4de + source = LICENSE_1.17.1+b341.md::https://raw.githubusercontent.com/PaperMC/Paper/f25facb/LICENSE.md + sha512sums = 706369d0181e8ca17d689b782adb75f165f40fbc2aff07791fb10ab9cb2805f27a6cc759d8d09bd5987806611b38441174b90c2104b19dc71ea668abb12766ec sha512sums = a4fcc9f28436c0163e9414f2793fcbd4f6ea74772230cdff4a628246eae2a8008688b3dfb94d433f8f0887cd7eea3fe43ce25f9d5812d46e62179ff315b62895 sha512sums = 51c5345155e8640d4f1eaef0c8cfb890ae46063f2d4e7a0fe181ad4c8ff7b96fea88b0f9fc74031d589dfd61602f37b440f183ca1859835930fe69d37508cd42 sha512sums = f29c4044d9e3cc5ab137c21f7e62399b36d7e1f777d5558a39f7b4a01de75bdf2de0b8678e424accc03934ca7db9ebb6a22c78c8c4497759287dd55e1c3eb456 sha512sums = fe268d7380f881229100700b1d4f4897904a630aa65b0b06bba08be5d5918f208d497e01fc5306deecd5d93a78cfdb7e9c7f1c3b910b3a414ce9af186a05224d - sha512sums = 4166db2684f41594128e25f036337f550f87697c7573d5c46e504c1deb994ef88a0f1b47527aa7e7e44d7cf03a1fcaa431d36293a29e9714bca60d5850be4f2d + sha512sums = 56c32b28ad6b3363e5de65860752457c780a1028314371319898b9896e3baec2bf662c64c59ea10a8efaf2273d014b5dfbd9c7bb66c6787de4b35e9341ca2582 sha512sums = c40cba5dfbf5af5d206cd42fa2b43f2321b481f83ab79c9ce4eaa76f204abab48ff2d8b8526a1a3d82636be97f18596d4343b0efc72a7082642e4af8d1b561c5 sha512sums = 115fe7213d7edd0e3159607a31b28edb6e6b3bd1d454d516973e38c8cf0b803275c2c4e59b29e2260561270d931c71bad134046535e5add309e0a8d055cde0ff sha512sums = 3caa140e6545b7d61a182874cf5578050ad3f74c7e95fc5643b8c7594672bbbd9161381aa9c93b51248e12e60c6411d47fbb426ce3c22389bc8161c17278382e @@ -4,10 +4,10 @@ pkgname=papermc # curl -X GET "https://papermc.io/api/v2/projects/paper" -H "accept: application/json" _pkgver=1.17.1 # curl -X GET "https://papermc.io/api/v2/projects/paper/versions/${_pkgver}" -H "accept: application/json" -_build=243 +_build=341 _license_commit=f25facb pkgver="${_pkgver}+b${_build}" -pkgrel=3 +pkgrel=1 pkgdesc="Next generation of Minecraft server, compatible with Spigot plugins and offering uncompromising performance" arch=('any') url="https://papermc.io/" diff --git a/papermc.sh b/papermc.sh index 4edfeec09aa4..db2ee09f912c 100755 --- a/papermc.sh +++ b/papermc.sh @@ -20,6 +20,7 @@ declare -r game="papermc" # Command and parameter declaration with which to start the server [[ -n "${SERVER_START_CMD}" ]] && declare -r SERVER_START_CMD=${SERVER_START_CMD} || SERVER_START_CMD="java -Xms512M -Xmx1024M -jar './${MAIN_EXECUTABLE}' nogui" +[[ -n "${SERVER_START_SUCCESS}" ]] && declare -r SERVER_START_SUCCESS=${SERVER_START_SUCCESS} || SERVER_START_SUCCESS="done" # System parameters for the control script [[ -n "${IDLE_SERVER}" ]] && tmp_IDLE_SERVER=${IDLE_SERVER} || IDLE_SERVER="false" @@ -43,6 +44,8 @@ set -u # Exit if a single command breaks and its failure is not handled accordingly set -e +MAX_SERVER_START_TIME=150 + # Check whether sudo is needed at all if [[ "$(whoami)" == "${GAME_USER}" ]]; then SUDO_CMD="" @@ -169,12 +172,38 @@ server_start() { else echo -en "Starting server..." ${SUDO_CMD} rm -f "${GAME_COMMAND_DUMP}" + # Use a plain file as command buffers for the server startup and switch to a FIFO pipe later + ${SUDO_CMD} touch "${GAME_COMMAND_DUMP}" + # Ensure pipe-pine is started before the server itself by splitting the session creation and server startup + ${SUDO_CMD} tmux -L "${SESSION_NAME}" new-session -s "${SESSION_NAME}" -c "${SERVER_ROOT}" -d /bin/bash + ${SUDO_CMD} tmux -L "${SESSION_NAME}" wait-for -L "command_lock" + ${SUDO_CMD} tmux -L "${SESSION_NAME}" pipe-pane -t "${SESSION_NAME}":0.0 "cat > ${GAME_COMMAND_DUMP}" + ${SUDO_CMD} tmux -L "${SESSION_NAME}" send-keys -t "${SESSION_NAME}":0.0 "exec ${SERVER_START_CMD}" Enter + for ((i=1; i<=MAX_SERVER_START_TIME; i++)); do + sleep "${sleep_time:-0.1}" + if ! socket_session_is_alive "${SESSION_NAME}"; then + echo -e "\e[39;1m failed\e[0m\n" + >&2 ${SUDO_CMD} cat "${GAME_COMMAND_DUMP}" + ${SUDO_CMD} rm -f "${GAME_COMMAND_DUMP}" + # Session is dead but remain-on-exit left it open; close it for sure + ${SUDO_CMD} tmux -L "${SESSION_NAME}" kill-session -t "${SESSION_NAME}" + exit 1 + elif grep -q -i "${SERVER_START_SUCCESS}" "${GAME_COMMAND_DUMP}"; then + echo -e "\e[39;1m done\e[0m" + break + elif [[ $i -eq ${MAX_SERVER_START_TIME} ]]; then + echo -e "\e[39;1m skipping\e[0m" + >&2 echo -e "Server startup has not finished yet; continuing anyways" + fi + done + ${SUDO_CMD} tmux -L "${SESSION_NAME}" pipe-pane -t "${SESSION_NAME}":0.0 + # Let the command buffer be a FIFO pipe + ${SUDO_CMD} rm -f "${GAME_COMMAND_DUMP}" ${SUDO_CMD} mkfifo "${GAME_COMMAND_DUMP}" - ${SUDO_CMD} tmux -L "${SESSION_NAME}" new-session -s "${SESSION_NAME}" -c "${SERVER_ROOT}" -d "${SERVER_START_CMD}" + ${SUDO_CMD} tmux -L "${SESSION_NAME}" wait-for -U "command_lock" # Mimic GNU screen and allow for both C-a and C-b as prefix ${SUDO_CMD} tmux -L "${SESSION_NAME}" set -g prefix2 C-a - echo -e "\e[39;1m done\e[0m" fi if [[ "${IDLE_SERVER,,}" == "true" ]]; then @@ -189,12 +218,12 @@ server_start() { ${SUDO_CMD} tmux -L "${SESSION_NAME}" kill-session -t "${IDLE_SESSION_NAME}" # Restart as soon as the idle_server_daemon has shut down completely for i in {1..100}; do + sleep 0.1 if ! socket_has_session "${IDLE_SESSION_NAME}"; then ${SUDO_CMD} tmux -L "${SESSION_NAME}" new-session -s "${IDLE_SESSION_NAME}" -d "${myname} idle_server_daemon" break fi [[ $i -eq 100 ]] && echo -e "An \e[39;1merror\e[0m occurred while trying to reset the idle_server!" - sleep 0.1 done else echo -en "Starting idle server daemon..." @@ -216,7 +245,7 @@ server_stop() { if socket_has_session "${IDLE_SESSION_NAME}"; then echo -en "Stopping idle server daemon..." - ${SUDO_CMD} tmux -L "${SESSION_NAME}" kill-session -t "${IDLE_SESSION_NAME}":0.0 + ${SUDO_CMD} tmux -L "${SESSION_NAME}" kill-session -t "${IDLE_SESSION_NAME}" echo -e "\e[39;1m done\e[0m" else echo "The corresponding tmux session for ${IDLE_SESSION_NAME} was already dead." @@ -285,7 +314,7 @@ server_status() { # Calculating memory usage for p in $(${SUDO_CMD} pgrep -f "${MAIN_EXECUTABLE}"); do ps -p"${p}" -O rss | tail -n 1; - done | gawk '{ count ++; sum += $2 }; END {count --; print "Number of processes =", count, "(tmux,", count-1, "x server)"; print "Total memory usage =", sum/1024, "MB" ;};' + done | gawk '{ count ++; sum += $2 }; END {count --; print "Number of processes =", count, "(tmux +", count, "x server)"; print "Total memory usage =", sum/1024, "MB" ;};' else echo -e "Status:\e[39;1m stopped\e[0m" fi @@ -429,13 +458,24 @@ server_console() { # Check if there is a session available socket_has_session() { if [[ "$(whoami)" != "${GAME_USER}" ]]; then - ${SUDO_CMD} tmux -L "${SESSION_NAME}" has-session -t "${1}":0.0 2> /dev/null - return $? + ${SUDO_CMD} tmux -L "${SESSION_NAME}" has-session -t "${1}":0.0 2> /dev/null + return $? fi tmux -L "${SESSION_NAME}" has-session -t "${1}":0.0 2> /dev/null return $? } +socket_session_is_alive() { + if socket_has_session "${1}"; then + if [[ "$(whoami)" != "${GAME_USER}" ]]; then + return $(${SUDO_CMD} tmux -L "${SESSION_NAME}" list-panes -t "${1}":0.0 -F '#{pane_dead}' 2> /dev/null) + fi + return $(tmux -L "${SESSION_NAME}" list-panes -t "${1}":0.0 -F '#{pane_dead}' 2> /dev/null) + else + return 1 + fi +} + # Help function, no arguments required help() { cat <<-EOF @@ -490,7 +530,7 @@ case "${1:-}" in ;; idle_server_daemon) - # This shall be a hidden function which should only be invoced internally + # This shall be a hidden function which should only be invoked internally idle_server_daemon ;; |