Permalink
Browse files

Allow receiver to reply to proxy process once it's up.

  • Loading branch information...
1 parent f604667 commit 147834fe1aa0fdd8801e1b7aea9d44d31d1c9adf @technomancy committed Nov 22, 2012
Showing with 11 additions and 1 deletion.
  1. +1 −1 bin/receiver
  2. +10 −0 lib/sokoban/receiver.rb
View
@@ -3,6 +3,6 @@
require "puma"
require "sokoban/receiver"
-s = Puma::Server.new(Sokoban::Receiver.new(ENV["REPO_URL"]))
+s = Puma::Server.new(Sokoban::Receiver.new(ENV["REPO_GET_URL"]))
s.add_tcp_listener("localhost", (ENV["PORT"] || 5000))
s.run.join
@@ -2,6 +2,8 @@
require 'rack/request'
require 'rack/response'
require 'rack/utils'
+require 'redis'
+require 'json'
require 'time'
module Sokoban
@@ -29,6 +31,8 @@ def initialize(repo_url)
system("curl --retry 3 --max-time 90 #{repo_url} > #{bundle}")
system("git bundle verify #{bundle}") or raise "Corrupt repo."
system("git clone --bare #{bundle} #{@repo_dir}")
+
+ reply
end
def call(env)
@@ -56,6 +60,12 @@ def route(req_method, req_path)
[:not_found]
end
+ def reply
+ host = UDPSocket.open { |s| s.connect("64.233.187.99", 1); s.addr.last }
+ reply = JSON.encode({:host => host, :port => ENV["PORT"]})
+ Redis.new(:url => ENV["REDIS_URL"]).lpush(ENV["REPLY_KEY"], reply)
+ end
+
# ---------------------------------
# actual command handling functions
# ---------------------------------

0 comments on commit 147834f

Please sign in to comment.