From dbee211506014f8aa415dfccab0941fcd3cfec6b Mon Sep 17 00:00:00 2001 From: Yehonal Date: Sun, 27 Jul 2025 13:50:20 +0200 Subject: fix(bash/starter): enhance interactive mode handling (#22516) This pull request updates the startup script in `apps/startup-scripts/src/starter` to improve handling of interactive and non-interactive modes, particularly when running under different session managers. ### Improvements to interactive and non-interactive mode handling: * Updated the condition to check if the application should run interactively by combining `AC_LAUNCHED_BY_PM2` and `AC_DISABLE_INTERACTIVE` environment variables. This ensures more accurate handling of interactive mode. Fixes: https://github.com/azerothcore/azerothcore-wotlk/issues/22507 --- apps/startup-scripts/src/starter | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) (limited to 'apps') diff --git a/apps/startup-scripts/src/starter b/apps/startup-scripts/src/starter index a802f6455d..4e58e8e7b4 100755 --- a/apps/startup-scripts/src/starter +++ b/apps/startup-scripts/src/starter @@ -122,12 +122,26 @@ EOF fi else echo "Starting $BINFILE without GDB" - if [[ "$AC_LAUNCHED_BY_PM2" == "1" ]]; then - echo "Running under PM2" + # Determine if PM2 is active + is_pm2_active="0" + [ "$AC_LAUNCHED_BY_PM2" == "1" ] && is_pm2_active="1" + + # Determine if interactive mode is enabled + is_interactive_enabled="1" + [ "$AC_DISABLE_INTERACTIVE" == "1" ] && is_interactive_enabled="0" + + # use normal execution if we are running the binary under PM2 + # or when interactive mode is enabled + if [[ "$is_pm2_active" == "1" || "$is_interactive_enabled" == "1" ]]; then + echo "Running AC" "$EXECPATH" ${CONFIG_ABS:+-c "$CONFIG_ABS"} else + # When AC_DISABLE_INTERACTIVE is set to 1 and we are not in PM2 + # This means we are using systemd without interactive mode and no session managers + # in this case we need to run AC with unbuffer for line-buffered output + # NOTE unbuffer doesn't fully support interactive mode if command -v unbuffer >/dev/null 2>&1; then - export AC_DISABLE_INTERACTIVE=0 + echo "Running AC with unbuffer for line-buffered output" unbuffer "$EXECPATH" ${CONFIG_ABS:+-c "$CONFIG_ABS"} else echo "⚠️ unbuffer not found, the output may not be line-buffered. Try installing expect." -- cgit v1.2.3