inotify 562 B

12345678910111213141516171819202122232425262728
  1. #!/usr/bin/env bash
  2. WORK_DIR=$1
  3. if [ ! -n "${WORK_DIR}" ] ;then
  4. WORK_DIR="."
  5. fi
  6. echo "Restarting LaravelS..."
  7. ./bin/laravels restart -d -i
  8. echo "Starting inotifywait..."
  9. LOCKING=0
  10. inotifywait --event modify --event create --event move --event delete -mrq ${WORK_DIR} | while read file
  11. do
  12. if [[ ! ${file} =~ .php$ ]] ;then
  13. continue
  14. fi
  15. if [ ${LOCKING} -eq 1 ] ;then
  16. echo "Reloading, skipped."
  17. continue
  18. fi
  19. echo "File ${file} has been modified."
  20. LOCKING=1
  21. ./bin/laravels reload
  22. LOCKING=0
  23. done
  24. exit 0