diff options
author | Yehonal <yehonal.azeroth@gmail.com> | 2025-07-27 13:50:20 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2025-07-27 13:50:20 +0200 |
commit | dbee211506014f8aa415dfccab0941fcd3cfec6b (patch) | |
tree | e6bf393b0c8cd24033e5782459d66466e1a6f856 /apps/startup-scripts/src | |
parent | 90ac29815554013d32fe497c3ca975622df1135c (diff) |
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
Diffstat (limited to 'apps/startup-scripts/src')
-rwxr-xr-x | apps/startup-scripts/src/starter | 20 |
1 files changed, 17 insertions, 3 deletions
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." |