Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 771
Vladimir Lebedev Avatar asked Mar 20 '23 02:03

Vladimir Lebedev


1 Answers

My development setup with sync consists of:

  • Installing sync to my exported ERL_LIBS path (i.e. $HOME/lib/erlang)
  • Creating a development relx config and executing it with relx -c relx-dev.config
  • Creating a simple shell script to cd into where the console script lives and execute it
  • Adding a config script to tweak my growl notifications

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.

like image 139
nu-ex Avatar answered Apr 27 '23 01:04

nu-ex