Created
June 15, 2025 13:07
-
-
Save shanemcd/37cb2486cc8eadf151cca54e5db1a5b8 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/env bash | |
if [ $# -lt 1 ]; then | |
echo "Usage:" | |
echo " autoreload directory" | |
exit 1 | |
fi | |
last_reload=`date +%s` | |
inotifywait -mrq -e create,delete,attrib,close_write,move $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" | |
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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment