awx/tools/docker-compose/awx-autoreload
Jeff Bradberry e8b2998578 Narrow down the inotifywait criteria for reloading the dev environment
- listen specifically within awx/awx, so that changes in awxkit or
  awx_collection don't trigger spurious reloads
- expand the exclude pattern to ignore the test directories
2022-06-13 16:08:20 -04:00

21 lines
549 B
Bash
Executable File

#!/bin/env bash
if [ $# -lt 2 ]; then
echo "Usage:"
echo " autoreload directory command"
exit 1
fi
last_reload=`date +%s`
inotifywait -mrq -e create,delete,attrib,close_write,move --exclude '(/awx_devel/awx/ui|/awx_devel/awx/.*/tests)' $1 | while read directory action file; do
this_reload=`date +%s`
since_last=$((this_reload-last_reload))
if [[ "$file" =~ .*py$ ]] && [[ "$since_last" -gt 1 ]]; then
echo "File changed: $file"
echo "Running command: $2"
eval $2
last_reload=`date +%s`
fi
done