Last active
June 21, 2016 10:00
-
-
Save pinglamb/fc535ac839e9017848243c810179a361 to your computer and use it in GitHub Desktop.
Control remote app like a charm
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
| #!/usr/bin/env bash | |
| # Dependencies: | |
| # - inotify-tools | |
| MY_PIDFILE=tmp/pids/my.pid | |
| PUMA_PIDFILE=tmp/pids/puma.pid | |
| nohup inotifywait -m tmp/restart.txt -e attrib -q | while read event; do | |
| test -e "$PUMA_PIDFILE" && pumactl --pidfile $PUMA_PIDFILE status | |
| if [ $? -ne 0 ] | |
| then | |
| puma config.ru -d --pidfile $PUMA_PIDFILE --redirect-stdout log/puma.log --redirect-stderr log/puma.log | |
| else | |
| pumactl --pidfile $PUMA_PIDFILE restart | |
| fi | |
| done > log/puma.log 2>&1& | |
| echo $! > $MY_PIDFILE |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment