Created
March 24, 2018 14:17
-
-
Save gouf/087b5a6912bef0e8ee0102066ec353dc to your computer and use it in GitHub Desktop.
Wach directory/files and run command repeatedly
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/sh | |
# About rerun: [alexch/rerun: Restarts an app when the filesystem changes. Uses growl and FSEventStream if on OS X.](https://github.com/alexch/rerun/) | |
# About yard: [YARD - A Ruby Documentation Tool](https://yardoc.org/) | |
# Note: specify `-d [directory where not same directory level of .yard]` option to avoid endless loop | |
rerun -d app -c "rm -rf .yard && yard doc && ./yard_server.sh restart" |
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/sh | |
# Original: https://stackoverflow.com/questions/8509177/how-i-can-run-yard-server-on-production-server | |
# For debug | |
# set -x | |
# set -e | |
# or you process here | |
PROCESS='ruby */yard server' | |
PID=`pidof $PROCESS` | |
start() { | |
# yard server & | |
yard server | |
} | |
stop() { | |
# if [ "$PID" ];then | |
# kill -KILL $PID | |
# echo 'yard is stopped' | |
# fi | |
# Add some process for rerun | |
for PID_S in $PID; do | |
NAME=`ps -p $PID_S -o comm=` | |
if [ "$PID_S" ] && [ "$NAME" != "rerun" ];then | |
kill -KILL $PID_S | |
echo 'yard is stopped' | |
fi | |
done | |
} | |
case "$1" in | |
start) | |
start | |
;; | |
stop) | |
stop | |
;; | |
restart) | |
stop | |
start | |
;; | |
*) | |
echo Usage: $0 [start|stop|restart] | |
;; | |
esac |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment