serf-handler
Serf Handler is a Crystal library and executable for handling HashiCorp Serf user events and queries.
Installation
-
Add the dependency to your
shard.yml:dependencies: serf-handler: github: wyhaines/serf-handler.cr -
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
- Fork it (https://github.com/your-github-user/serf-handler/fork)
- Create your feature branch (
git checkout -b my-new-feature) - Commit your changes (
git commit -am 'Add some feature') - Push to the branch (
git push origin my-new-feature) - Create a new Pull Request
Contributors
- Kirk Haines - creator and maintainer