module Perkins #this should be a daemon #it will listen incoming messages #it will run the propper repo with runner commands #it will pass the message to other daemon to notify #it will deploy ? class Listener attr_accessor :app def run! #chan't use the same $redis conn because it fails #TODO: reconnect with same settings redis_conn = Redis.new() redis_conn.subscribe('perkins:commits') do |on| on.message do |channel, msg| exec_runner(channel, msg) end end end def exec_runner(channel, msg) data = JSON.parse(msg) puts "##{channel} - [#{data['name']}]: #{data['sha']}" repo = Perkins::Repo.find(data["id"]) #Thread.new do Worker.perform(repo, data['sha'], data['branch'] ) #end end end end