[![Build Status](](

# Cowbell
**Cowbell** is an Erlang node connection manager.

## Introduction
Erlang nodes do not automatically reconnect when a node gets disconnected. For instance, when net splits happen, the nodes in a cluster might get disconnected and action needs to be taken to reconnect them again.

Cowbell automatically manages the connections & reconnections for you.

## Install

### Rebar3
If you're using [rebar3](, add `cowbell` as a dependency in your project's `rebar.config` file:

{syn, {git, "git://", {tag, "0.1.0"}}}

Or, if you're using []( as package manager (with the [rebar3_hex]( plugin):

{cowbell, "0.1.0"}

Then, compile:

$ rebar3 compile

### Rebar2
If you're using [rebar](, add `cowbell` as a dependency in your project's `rebar.config` file:

{syn, ".*", {git, "git://", {tag, "0.1.0"}}}

Then, get and compile your dependencies:

$ rebar get-deps
$ rebar compile

## Usage

### Setup
Ensure that Cowbell is started from your application. This can be done by either providing it as a dependency in your `.app` file, or by starting it manually:


### Specify Nodes & Options
Nodes and options can be set in the environment variable `cowbell`. You're probably best off using an application configuration file (in releases, `sys.config`):

{cowbell, [

    %% check interval for nodes events (Default: 10)
    %% {check_interval_sec, 10},

    %% abandon a node after unsuccessful reconnect (Default: 86400)
    %% {abandon_node_after_sec, 86400},

    %% list of nodes to connect to and monitor
    {nodes, [
        %% 'cowbell@'


Your application will have its own logic on when to connect to the other nodes in the cluster. To connect to the nodes and start monitoring for disconnections, issue:


The recommended place to do so is in the `start/2` function in your main application module, something along the lines of:


-export([start/2, stop/1]).

start(_StartType, _StartArgs) ->
    %% connect to nodes
    %% start sup

Cowbell will then start monitoring nodes.

## Why "Cowbell"?
_"A cow bell or cowbell is a bell worn by freely roaming livestock, making animals easier to locate should they wander off."_
- From [Wikipedia](

## Contributing
So you want to contribute? That's great! Please follow the guidelines below. It will make it easier to get merged in.

Before implementing a new feature, please submit a ticket to discuss what you intend to do. Your feature might already be in the works, or an alternative implementation might have already been discussed.

Do not commit to master in your fork. Provide a clean branch without merge commits. Every pull request should have its own topic branch. In this way, every additional adjustments to the original pull request might be done easily, and squashed with `git rebase -i`. The updated branch will be visible in the same pull request, so there will be no need to open new pull requests when there are changes to be applied.

Ensure to include proper testing. To run tests you simply have to be in the project's root directory and run:

$ make tests