serf-handler

Serf-Handler CI GitHub release GitHub commits since latest release (by SemVer)

Serf Handler is a Crystal library and executable for handling HashiCorp Serf user events and queries.

Installation

  1. Add the dependency to your shard.yml:

    dependencies:
      serf-handler:
        github: wyhaines/serf-handler.cr
  2. Run shards install

Usage

Build the executable from this repository and point your Serf agent at it.

shards build --release
serf agent -event-handler=/path/to/bin/serf-handler

With the agent running, use serf query ping to check uptime or serf query list-handlers to list the available handlers. Serf limits query responses to 1024 bytes by default.

Run a handler manually with bin/serf-handler -t query -n load-average. Use -p to supply a payload.

To add your own handlers, require the shard in a custom executable and call SerfHandler.run after registering them.

require "serf-handler"
include SerfHandler

describe "Log an announcement from another cluster member."
on :event, "announce" do |event|
  STDERR.puts event.payload
end

SerfHandler.run

Point the agent at your custom executable, then send an announcement with serf event announce 'Hello, cluster'.

Development

shards install
crystal spec
shards build
crystal tool format --check
crystal build -o bin/ameba lib/ameba/src/cli.cr
bin/ameba

Contributing

  1. Fork it (https://github.com/your-github-user/serf-handler/fork)
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create a new Pull Request

Contributors

GitHub code size in bytes GitHub issues