Search code examples
database-replicationriak

How to add a replication hook to Riak v2.0+


Background

Riak v2.0 changed the configuration system from:

  • vm.args (set of erlang parameters for the Riak node)
  • app.config (configuration of various attributes for the Riak node)

to:

  • riak.conf (replacing the majority of what was in vm.args and app.conf with a single configuration file [using named settings])
  • advanced.config (a small specific set of settings [mostly related to riak_repl])

Question

In Multi-Data-Center-Replication-Hooks the Riak v2.0+ documentation still refers to:

Add a -pa argument to your vm.args file to specify the path where your compiled .beam file lives:

Shell -pa /path/to/replication/hook Finally, add a -run argument to your vm.args file to register the hook:

Shell -run riak_repl_hook_sample register

What are the riak.conf or advanced.config versions of the -pa & -run parameters?


Note: I know that in the doc:Upgrading Your Configuration System we can:

Keep your configuration files from the older system, which are still recognized in Riak 2.0.

but we would like to move to the new configuration system as it gives us more visibility.


Solution

  • in your advanced.config file, try someting like that:

    [
     {riak_kv, [
                {add_paths, ["/path/to/replication/hook"]}
               ]},
     {vm_args, [
                {'-run riak_repl_hook_sample register', ""}
               ]}
    ].
    

    I know that starting an app works, I'm using this:

    [
     {riak_kv, [
                {add_paths, ["/path/to/my/beams/"]}
               ]},
     {vm_args, [
                {'-s my_app', ""}
               ]}
    ].
    

    So with a little fiddling you should be able to make it work :)