From a533a7ca49750bddeedadb90832133d8740537ce Mon Sep 17 00:00:00 2001 From: Hao Liu <44379968+TheRealHaoLiu@users.noreply.github.com> Date: Wed, 6 Mar 2024 14:49:24 -0500 Subject: [PATCH] Not auto-reload explicitly STOPPED processes In development/debug workflow sometime we explicitly STOP processes this will make sure auto-reload does not start them back up --- Makefile | 4 +--- .../dockerfile/templates/supervisor_rsyslog.conf.j2 | 2 +- .../dockerfile/templates/supervisor_task.conf.j2 | 2 +- .../roles/dockerfile/templates/supervisor_web.conf.j2 | 2 +- tools/docker-compose/awx-autoreload | 11 +++++++++-- 5 files changed, 13 insertions(+), 8 deletions(-) diff --git a/Makefile b/Makefile index a78e666ee779..50e3f7c77d44 100644 --- a/Makefile +++ b/Makefile @@ -216,8 +216,6 @@ collectstatic: fi; \ $(PYTHON) manage.py collectstatic --clear --noinput > /dev/null 2>&1 -DEV_RELOAD_COMMAND ?= supervisorctl restart tower-processes:* - uwsgi: collectstatic @if [ "$(VENV_BASE)" ]; then \ . $(VENV_BASE)/awx/bin/activate; \ @@ -225,7 +223,7 @@ uwsgi: collectstatic uwsgi /etc/tower/uwsgi.ini awx-autoreload: - @/awx_devel/tools/docker-compose/awx-autoreload /awx_devel/awx "$(DEV_RELOAD_COMMAND)" + @/awx_devel/tools/docker-compose/awx-autoreload /awx_devel/awx daphne: @if [ "$(VENV_BASE)" ]; then \ diff --git a/tools/ansible/roles/dockerfile/templates/supervisor_rsyslog.conf.j2 b/tools/ansible/roles/dockerfile/templates/supervisor_rsyslog.conf.j2 index 8d8501ea6569..e516c208e311 100644 --- a/tools/ansible/roles/dockerfile/templates/supervisor_rsyslog.conf.j2 +++ b/tools/ansible/roles/dockerfile/templates/supervisor_rsyslog.conf.j2 @@ -36,7 +36,7 @@ stderr_logfile_maxbytes=0 {% if kube_dev | bool %} [program:awx-autoreload] -command = /awx_devel/tools/docker-compose/awx-autoreload /awx_devel/awx 'supervisorctl -c /etc/supervisord_rsyslog.conf restart tower-processes:*' +command = /awx_devel/tools/docker-compose/awx-autoreload /awx_devel/awx autostart = true autorestart = true stopasgroup=true diff --git a/tools/ansible/roles/dockerfile/templates/supervisor_task.conf.j2 b/tools/ansible/roles/dockerfile/templates/supervisor_task.conf.j2 index bce0a8752a02..90b6313635b2 100644 --- a/tools/ansible/roles/dockerfile/templates/supervisor_task.conf.j2 +++ b/tools/ansible/roles/dockerfile/templates/supervisor_task.conf.j2 @@ -58,7 +58,7 @@ stderr_logfile_maxbytes=0 {% if kube_dev | bool %} [program:awx-autoreload] -command = /awx_devel/tools/docker-compose/awx-autoreload /awx_devel/awx 'supervisorctl -c /etc/supervisord_task.conf restart tower-processes:*' +command = /awx_devel/tools/docker-compose/awx-autoreload /awx_devel/awx autostart = true autorestart = true stopasgroup=true diff --git a/tools/ansible/roles/dockerfile/templates/supervisor_web.conf.j2 b/tools/ansible/roles/dockerfile/templates/supervisor_web.conf.j2 index 6112b6abdafe..d156b97dfad9 100644 --- a/tools/ansible/roles/dockerfile/templates/supervisor_web.conf.j2 +++ b/tools/ansible/roles/dockerfile/templates/supervisor_web.conf.j2 @@ -91,7 +91,7 @@ stderr_logfile_maxbytes=0 {% if kube_dev | bool %} [program:awx-autoreload] -command = /awx_devel/tools/docker-compose/awx-autoreload /awx_devel/awx 'supervisorctl -c /etc/supervisord_web.conf restart tower-processes:*' +command = /awx_devel/tools/docker-compose/awx-autoreload /awx_devel/awx autostart = true autorestart = true stopasgroup=true diff --git a/tools/docker-compose/awx-autoreload b/tools/docker-compose/awx-autoreload index 0f6f0b8f9df1..37507c2451af 100755 --- a/tools/docker-compose/awx-autoreload +++ b/tools/docker-compose/awx-autoreload @@ -13,8 +13,15 @@ inotifywait -mrq -e create,delete,attrib,close_write,move --exclude '(/awx_devel since_last=$((this_reload-last_reload)) if [[ "$file" =~ ^[^.].*\.py$ ]] && [[ "$since_last" -gt 1 ]]; then echo "File changed: $file" - echo "Running command: $2" - eval $2 + # if SUPERVISOR_CONFIG_PATH is defined run `supervisorctl -c $SUPERVISOR_CONFIG_PATH` else just run `supervisorctl` + if [ -n "$SUPERVISOR_CONFIG_PATH" ]; then + supervisorctl_command="supervisorctl -c $SUPERVISOR_CONFIG_PATH" + else + supervisorctl_command="supervisorctl" + fi + tower_processes=`$supervisorctl_command status tower-processes:* | grep -v STOPPED | awk '{print $1}' | tr '\n' ' '` + echo echo "Running command: $supervisorctl_command restart $tower_processes" + eval $supervisorctl_command restart $tower_processes last_reload=`date +%s` fi done