active
Active is an Erlang application that triggers rebuilds according to source changes. Active is also a new sync.
The key features are:
active
no longer hogs disk and cpu to check for changes. Instead, it uses erlfsmon to observe filesystem events.active
uses rebar directly to build sources. This leveragesrebar
to build all kinds of source files that it can build includingerlydtl
templates.
An extremely simplified version of active
can look like this (however it does not load any code):
# cat Makefile
sync:
fsevent_watch -F . \
| tee /dev/stderr \
| env PERLIO=:raw perl -ne 's#.*\t.*\t$$ENV{"PWD"}/(apps|deps)/(\w+)/(?!ebin)#\2# && print "$$1=$$2\n"' \
| xargs -n1 rebar compile
Setting up
Just add a line to rebar.config
:
{active, ".*", {git, "git://github.com/proger/active", "HEAD"}}
And make sure you start it along in your release boot scripts or application startup scripts:
ERL_LIBS=deps erl -pa ebin -config sys.config \
-eval '[ok = application:ensure_started(A, permanent) || A <- [sasl,lager,gproc,erlfsmon,compiler,crypto,syntax_tools,tools,rebar,active]]'
That's it!
Caveats
rebar
depends onsasl
. If you don't wish to see large SASL logs (e.g. you uselager
), turn them off in your config:
{sasl, [{sasl_error_logger, false}]}
rebar
writes to stdout by default. If you wish to change this behaviour, you may redefineconsole_log_function
andlog_function
variables. (this is pending merge to upstream,active
currently uses my fork of rebar anyway)
{rebar, [
{log_function, {error_logger, format}},
{console_log_function, {error_logger, format}}
]}
- due to the fact that
rebar
changes code paths while running, your regular rebar escript executable may fail. Make sure your rebar escript is as fresh as possible if it fails (take one from my fork)