Skip to content

Instantly share code, notes, and snippets.

@BernardNotarianni
Last active August 29, 2015 13:58
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save BernardNotarianni/10292724 to your computer and use it in GitHub Desktop.
Save BernardNotarianni/10292724 to your computer and use it in GitHub Desktop.
Continuous build for erlang (cowboy, erlydtl...)
#!/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