Skip to content

Instantly share code, notes, and snippets.

@DerMitch
Created October 31, 2013 15:33
Show Gist options
  • Save DerMitch/7251790 to your computer and use it in GitHub Desktop.
Save DerMitch/7251790 to your computer and use it in GitHub Desktop.
auto-reload supervisord config on changes
#!/bin/sh
# auto-reload supervisor config on a config file change
# Licensed under Public Domain
# apt-get install inotify-tools
while true; do
inotifywait --quiet --recursive --event create,close_write /etc/supervisor/
supervisorctl reread
supervisorctl update
done
@LiamKarlMitchell
Copy link

In WSL 2 Docker container inotify is not working I'm not sure why/how to fix this just yet but it should be fixed in future versions.
For now I will just poll an md5 of the config sharing here in-case it helps anyone. Cheers for the example @DerMitch

#!/bin/sh
# auto-reload supervisor config on a config file change
# Licensed under Public Domain

FILE="/etc/supervisor/conf.d/supervisord.conf"
LAST=`md5sum "$FILE"`
while true; do
  sleep 1
  NEW=`md5sum "$FILE"`
  if [ "$NEW" != "$LAST" ]; then
    supervisorctl reread
    supervisorctl update
    LAST="$NEW"
  fi
done

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment