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
This commit is contained in:
Yehonal 2025-07-27 13:50:20 +02:00 committed by GitHub
parent 90ac298155
commit dbee211506
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -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."