[erlang-questions] "Automatic" recompile app from a console

Diego Llarrull <>
Fri Feb 1 21:01:10 CET 2013


Hello everyone,

I'm working on a riak_core based project, that is, one which uses rebar 
+ GNU make and where the src files are located  in different folders 
than the beam files, which are inside inside zipped (.ez) files.

sync + libnotify will do the trick for unzipped files, but some extra 
trickery was needed to load the new .beam files

a) compile the modified sources
b) (create and) run a script that generates the .zip files containing 
the .beams and deploys those files in their destination directory
c) run the following code:

reload() ->
     Modules = [ X || {X,L} <- code:all_loaded(), 
is_list(L),string:str(L, ?PATH_TO_CODE_DIR) =/= 0],
     lists:map(fun(X) -> c:l(X) end, Modules).

Hope this helps anyone, right now I'm trying out ssync to see if it is 
able to handle zipped files.

Best regards,

Diego

On 01/02/13 16:09, Serge Aleynikov wrote:
> Hi Scott,
>
> Nice to know I'm not the only one finding it useful!  ;-)
>
> Other than for auto-compilation/loading of erlydtl templates, I also
> find that having control over the moment of code loading is more
> advantageous, as the function shows what modules were loaded, so you
> know what version of code is running.
>
> Concerning the user_default, I believe I added a couple more useful
> functions there (i.e tc/2, tc/4) after I published this module a while
> back.  Enjoy!  ;-)
>
> Serge
>
> On 2/1/2013 1:21 PM, Scott Lystig Fritchie wrote:
>> Serge Aleynikov <> wrote:
>>
>> sa> [1] https://github.com/saleyn/util/blob/master/src/user_default.erl
>>
>> Howdy, Serge.  I've been using the l() function from that
>> user_default.erl module for years.  It's tremendously handy.  There are
>> times where I want to reload several modules after recompiling but load
>> them sometime at my choosing rather than immediately after the compiler
>> is done.  l() does that.
>>
>> -Scott
>>
> _______________________________________________
> erlang-questions mailing list
> 
> http://erlang.org/mailman/listinfo/erlang-questions




More information about the erlang-questions mailing list