Merge pull request #12054 from shanemcd/new-autoreloader

Alternative code reloader for dev env
This commit is contained in:
Shane McDonald 2022-04-14 11:18:13 -04:00 committed by GitHub
commit 778862fe51
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 38 additions and 13 deletions

View File

@ -177,7 +177,7 @@ collectstatic:
fi; \
mkdir -p awx/public/static && $(PYTHON) manage.py collectstatic --clear --noinput > /dev/null 2>&1
UWSGI_DEV_RELOAD_COMMAND ?= supervisorctl restart tower-processes:awx-dispatcher tower-processes:awx-receiver
DEV_RELOAD_COMMAND ?= supervisorctl restart tower-processes:*
uwsgi: collectstatic
@if [ "$(VENV_BASE)" ]; then \
@ -192,12 +192,13 @@ uwsgi: collectstatic
--processes=5 \
--harakiri=120 --master \
--no-orphans \
--py-autoreload 1 \
--max-requests=1000 \
--stats /tmp/stats.socket \
--lazy-apps \
--logformat "%(addr) %(method) %(uri) - %(proto) %(status)" \
--hook-accepting1="exec: $(UWSGI_DEV_RELOAD_COMMAND)"
--logformat "%(addr) %(method) %(uri) - %(proto) %(status)"
awx-autoreload:
@/awx_devel/tools/docker-compose/awx-autoreload /awx_devel "$(DEV_RELOAD_COMMAND)"
daphne:
@if [ "$(VENV_BASE)" ]; then \

View File

@ -158,6 +158,8 @@ RUN pip3 install black git+https://github.com/coderanger/supervisor-stdout
# It is nice to have in the dev env, but not necessary.
# Add it back to the list above if the repo ever straighten up.
RUN dnf --enablerepo=baseos-debug -y install python3-debuginfo || :
RUN dnf install -y epel-next-release && dnf install -y inotify-tools && dnf remove -y epel-next-release
{% endif %}
# Copy app from builder

View File

@ -27,7 +27,7 @@ stderr_logfile_maxbytes=0
command = make uwsgi
directory = /awx_devel
environment =
UWSGI_DEV_RELOAD_COMMAND='supervisorctl -c /etc/supervisord_task.conf restart all; supervisorctl restart tower-processes:daphne tower-processes:wsbroadcast'
DEV_RELOAD_COMMAND='supervisorctl -c /etc/supervisord_task.conf restart all; supervisorctl restart tower-processes:daphne tower-processes:wsbroadcast'
{% else %}
command = /var/lib/awx/venv/awx/bin/uwsgi /etc/tower/uwsgi.ini
directory = /var/lib/awx

View File

@ -0,0 +1,15 @@
#!/bin/env bash
if [ $# -lt 2 ]; then
echo "Usage:"
echo " autoreload directory command"
exit 1
fi
inotifywait -mrq -e create,delete,attrib,close_write,move --exclude '/awx_devel/awx/ui' $1 | while read directory action file; do
if [[ "$file" =~ .*py$ ]]; then
echo "File changed: $file"
echo "Running command: $2"
eval $2
fi
done

View File

@ -6,7 +6,6 @@ nodaemon=true
[program:awx-dispatcher]
command = make dispatcher
autorestart = true
startsecs = 30
stopasgroup=true
killasgroup=true
stdout_logfile=/dev/stdout
@ -17,7 +16,6 @@ stderr_logfile_maxbytes=0
[program:awx-receiver]
command = make receiver
autorestart = true
startsecs = 30
stopasgroup=true
killasgroup=true
stdout_logfile=/dev/stdout
@ -28,7 +26,6 @@ stderr_logfile_maxbytes=0
[program:awx-wsbroadcast]
command = make wsbroadcast
autorestart = true
startsecs = 30
autorestart = true
stopasgroup=true
killasgroup=true
@ -40,7 +37,8 @@ stderr_logfile_maxbytes=0
[program:awx-uwsgi]
command = make uwsgi
autorestart = true
startsecs = 30
stopwaitsecs = 1
stopsignal=KILL
stopasgroup=true
killasgroup=true
stdout_logfile=/dev/stdout
@ -51,7 +49,6 @@ stderr_logfile_maxbytes=0
[program:awx-daphne]
command = make daphne
autorestart = true
startsecs = 30
stopasgroup=true
killasgroup=true
stdout_logfile=/dev/stdout
@ -62,7 +59,6 @@ stderr_logfile_maxbytes=0
[program:awx-nginx]
command = make nginx
autorestart = true
startsecs = 30
stopasgroup=true
killasgroup=true
stdout_logfile=/dev/stdout
@ -73,7 +69,6 @@ stderr_logfile_maxbytes=0
[program:awx-rsyslogd]
command = rsyslogd -n -i /var/run/awx-rsyslog/rsyslog.pid -f /var/lib/awx/rsyslog/rsyslog.conf
autorestart = true
startsecs = 30
stopasgroup=true
killasgroup=true
redirect_stderr=true
@ -83,7 +78,6 @@ stderr_events_enabled = true
[program:awx-receptor]
command = receptor --config /etc/receptor/receptor.conf
autorestart = true
startsecs = 30
stopasgroup=true
killasgroup=true
stdout_logfile=/dev/stdout
@ -95,6 +89,19 @@ stderr_logfile_maxbytes=0
programs=awx-dispatcher,awx-receiver,awx-uwsgi,awx-daphne,awx-nginx,awx-wsbroadcast,awx-rsyslogd
priority=5
[program:awx-autoreload]
command = make awx-autoreload
autostart = true
autorestart = true
stopasgroup=true
killasgroup=true
stdout_logfile=/dev/stdout
stdout_logfile_maxbytes=0
stderr_logfile=/dev/stderr
stderr_logfile_maxbytes=0
stdout_events_enabled = true
stderr_events_enabled = true
[eventlistener:superwatcher]
command=stop-supervisor
events=PROCESS_STATE_FATAL