erlangcowboyrelx

How to use sync properly with application built using relx release assembler?


I would like to use Sync on-the-fly recompiling with Cowboy project assembled using relx (as per Cowboy Getting Started Guide).

The problem is that even if I manage to get Sync starting in my application by mentioning sync in applications list in my_application.app.src file like this:

{application, my_application, [
    {description, "My Cowboy Application"},
    {vsn, "0.1.0"},
    {modules, []},
    {registered, [my_app_sup]},
    {applications, [
        kernel,
        stdlib,
        cowboy,
        sync
    ]},
    {mod, {my_app, []}},
    {env, []}
]}.`

I still can't get it working because of relx assembler does not move my source code to _rel directory (of course, it shouldn't).

Is there any way to tell Sync where my source files are located? Or may be I'm totally wrong and Sync integration with relx must be done in some other way?


Solution

  • My development setup with sync consists of:

    When developing, I include sync in my development relx.config file. However, once I install sync in a directory and export it to ERL_LIBS, it magically appears when I start the sync app in any of my erlang projects.

    Here is an example of my development relx-dev.config file:

    {dev_mode, true}.
    {lib_dirs, ["/usr/local/erlang"]}.
    {output_dir, "_rel-dev"}.
    {release,
     {myapp, "0.0.1"},
     [{myapp_core, "0.0.1", '='}, sasl, syntax_tools, compiler, sync]
    }.
    {extended_start_script, true}.
    

    Once the relx-dev.config script is created, I build the release with this command:

    relx -c relx-dev.config
    

    Here is the console script I use to start the console:

    #!/usr/bin/sh
    _rel-dev/myapp/bin/myapp console
    

    This script will start an erlang shell with a node name, start all of my apps and the the sync application and load a custom sync config file.

    Here is an example sync.config file placed in the same directory where you started the shell:

    [{sync, [{growl, [errors, warnings]}]}].
    

    The sync README has lots of info about configuring logging behavior for the console and growl. Alternatives to using a .config file include passing options to the erl command and executing sync functions in the shell.