Last active
August 29, 2015 13:58
-
-
Save BernardNotarianni/10292724 to your computer and use it in GitHub Desktop.
Continuous build for erlang (cowboy, erlydtl...)
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/bash | |
# the name of your erlang app | |
APPNAME=yourappname | |
# we will monitor for any modification in those directories | |
WATCHEDDIRS="src templates" | |
# --- Functions | |
function title { | |
echo -en "\033]2;$1\007" | |
} | |
function stop_server { | |
# kill previous server and tail log | |
kill %1 %2 &> /dev/null | |
rm -f log/* | |
} | |
function ctrl_c { | |
echo "** Trapped CTRL-C" | |
stop_server | |
exit | |
} | |
# --- Start | |
trap ctrl_c INT TERM EXIT | |
export LOGIN=`whoami` | |
echo "Continuous assets build for $APPNAME" | |
echo "<ctrl>-C to quit." | |
while true; do | |
echo "" | |
title "circus build" | |
stop_server | |
echo "" | |
echo "start build..." | |
make | |
if [ $? == 0 ] | |
then | |
echo "Start server" | |
export RUN_ERL_LOG_MAXSIZE=100000000 | |
export RUN_ERL_LOG_GENERATIONS=2 | |
run_erl /tmp/ . "exec erl -pa ebin -pa deps/*/ebin -mnesia dir '\"mnesia\"' -s "$APPNAME"_app -sname "$APPNAME" -setcookie "$APPNAME$LOGIN & | |
sleep 1 | |
tail -f ./erlang.log.1& | |
fi | |
echo "" | |
date +"%k:%M:%S - Wait for source modification in [$WATCHEDDIRS] - Server listening" | |
title "circus" | |
inotifywait -qr -e modify -e create -e move -e delete $WATCHEDDIRS --exclude "\.\#.*" | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment