Chain Reactor is a simple server that waits for incoming connections, then kicks off some code when one is made. Clients are locked down by IP address, so you will only recieve connections from known clients. Also, data can be passed via JSON, XML, or anything you like.
The “reactions” are written in ruby code, like this:
react_to '192.168.0.1' do |data| puts "Hello, 192.168.0.1, I'm going to do something now!" puts data.inspect #=> Prints a hash end
It really is that easy. Also, you can respond to multiple clients with the same code block:
react_to ['192.168.0.1','192.168.0.2'] do |data| puts "Hello, I'm going to do something now!" end
It can be run as a daemon, multithreaded (each client connection in a new thread), and bind to different addresses and ports.
This project started as a way of notifying other machines about builds happening on Jenkins, our continuous integration server. A chain reactor server would be sitting, listening for connections. When a build fails or passes on Jenkins, it lets the chain reactor server(s) know, pushing the build data. The chain reactor server then does what it likes, and the Jenkins server doesn't need to know.
I'm sure this has plenty of other uses, but it works great with continuous integration set-ups.
This can be installed through ruby gems:
$ gem install chain-reactor
Chain reactor comes with two command line tools,
chain-reactor (the server) and
chain-reactor-client (I think you can guess).
A chain file is required to run the server, as this specifies which clients to accept and what to do. Fortunately, it's easy to create a template:
$ chain-reactor template > Chainfile.rb
Open it up and edit it to your liking. You might want to test it locally first, i.e. only react to 127.0.0.1 addresses. In one terminal, run:
$ chain-reactor start Chainfile.rb --ontop
The –ontop option stops it from running as a daemon, making it easier to see what's happening. By default, the chain reactor server runs on port 1987, but that's configurable if you want to change it. In another terminal, run the client with:
$ chain-reactor-client --address 127.0.0.1
Follow the instructions by adding key/value pair data to send to the server, then watch it react!
For more information on configuration, take a look at the wiki.
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 new Pull Request