mirror of
https://github.com/mod-playerbots/azerothcore-wotlk.git
synced 2026-01-16 10:30:27 +00:00
feat: improve session management and PM2 support in startup scripts (#22420)
New feature to manage service restart policies and refactors crash logging paths for better flexibility and clarity. The most significant changes include adding support for configurable restart policies (`on-failure` and `always`), updating documentation to reflect these changes, and improving crash path handling in multiple scripts.
This commit is contained in:
@@ -26,7 +26,7 @@ CRASHES_PATH="$8"
|
||||
|
||||
# Default values
|
||||
CURRENT_PATH="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
DEFAULT_CRASHES_PATH="$CURRENT_PATH/logs/crashes"
|
||||
DEFAULT_CRASHES_PATH=$(realpath "$BINPATH/crashes")
|
||||
[ -n "$CONFIG" ] && CONFIG_ABS=$(realpath "$CONFIG")
|
||||
|
||||
# Set defaults if not provided
|
||||
@@ -121,20 +121,17 @@ EOF
|
||||
rm -f "$GDB_TEMP_FILE"
|
||||
fi
|
||||
else
|
||||
# check if it's running under PM2 or `script` command does not exist
|
||||
# Note: script is used to capture output in non-interactive sessions such as systemd (without tmux/screen)
|
||||
# We use AC_LAUNCHED_BY_PM2 environment variable set by service-manager for robust PM2 detection
|
||||
if [[ "$AC_LAUNCHED_BY_PM2" == "1" || ! -x "$(command -v script)" ]]; then
|
||||
if [ -n "$CONFIG_ABS" ]; then
|
||||
"$EXECPATH" -c "$CONFIG_ABS"
|
||||
else
|
||||
"$EXECPATH"
|
||||
fi
|
||||
echo "Starting $BINFILE without GDB"
|
||||
if [[ "$AC_LAUNCHED_BY_PM2" == "1" ]]; then
|
||||
echo "Running under PM2"
|
||||
"$EXECPATH" ${CONFIG_ABS:+-c "$CONFIG_ABS"}
|
||||
else
|
||||
if [ -n "$CONFIG_ABS" ]; then
|
||||
script -q -e -c "$EXECPATH -c \"$CONFIG_ABS\""
|
||||
if command -v unbuffer >/dev/null 2>&1; then
|
||||
export AC_DISABLE_INTERACTIVE=0
|
||||
unbuffer "$EXECPATH" ${CONFIG_ABS:+-c "$CONFIG_ABS"}
|
||||
else
|
||||
script -q -e -c "$EXECPATH"
|
||||
echo "⚠️ unbuffer not found, the output may not be line-buffered. Try installing expect."
|
||||
exec "$EXECPATH" ${CONFIG_ABS:+-c "$CONFIG_ABS"}
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
Reference in New Issue
Block a user