Commit 7a37ea46 authored by John E. Vincent's avatar John E. Vincent

working webhook-only agent. See http://goo.gl/mGoSP

parent 59d284c9
...@@ -4,6 +4,8 @@ require 'rubygems' ...@@ -4,6 +4,8 @@ require 'rubygems'
require 'logger' require 'logger'
require 'optparse' require 'optparse'
require 'em-hiredis' require 'em-hiredis'
require 'eventmachine'
require 'em-http-request'
require 'thin' require 'thin'
require 'noah' require 'noah'
require 'json' require 'json'
...@@ -29,6 +31,15 @@ class EventMachine::NoahAgent ...@@ -29,6 +31,15 @@ class EventMachine::NoahAgent
EM::Iterator.new(matches).each do |watch, iter| EM::Iterator.new(matches).each do |watch, iter|
p, ep = Base64.decode64(watch).split("|") p, ep = Base64.decode64(watch).split("|")
logger.info("Sending message to: #{ep} for pattern: #{p}") logger.info("Sending message to: #{ep} for pattern: #{p}")
http = EM::HttpRequest.new(ep, :connection_timeout => 2, :inactivity_timeout => 4).post :body => message
http.callback {
LOGGER.debug("Message posted to #{ep} successfully")
#iter.next
}
http.errback {
LOGGER.debug("Something went wrong")
#iter.net
}
iter.next iter.next
end end
} }
...@@ -71,7 +82,7 @@ EventMachine.run do ...@@ -71,7 +82,7 @@ EventMachine.run do
r.on(:pmessage) do |pattern, event, message| r.on(:pmessage) do |pattern, event, message|
noah.reread_watchers if event =~ /^\/\/noah\/watcher\/.*/ noah.reread_watchers if event =~ /^\/\/noah\/watcher\/.*/
master_channel.push "#{event}|#{message}" master_channel.push "#{event}|#{message}"
logger.debug("Publishing [#{event}]") logger.debug("Saw[#{event}]")
end end
sub = master_channel.subscribe {|msg| sub = master_channel.subscribe {|msg|
......
...@@ -9,7 +9,6 @@ end ...@@ -9,7 +9,6 @@ end
require 'haml' require 'haml'
require 'yaml' require 'yaml'
require 'sinatra/base' require 'sinatra/base'
require 'sinatra/namespace'
require File.join(File.dirname(__FILE__), 'noah','validations') require File.join(File.dirname(__FILE__), 'noah','validations')
require File.join(File.dirname(__FILE__), 'noah','models') require File.join(File.dirname(__FILE__), 'noah','models')
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment