Browse files

Receiver just sends URL, not json.Explicitly require json.

  • Loading branch information...
1 parent a7f0694 commit 2222bbc35ad55c272df0a646a0eb5bcf4ce6fc80 @technomancy committed Nov 26, 2012
Showing with 6 additions and 8 deletions.
  1. +3 −4 lib/sokoban.rb
  2. +3 −4 lib/sokoban/receiver.rb
View
7 lib/sokoban.rb
@@ -55,7 +55,8 @@ def call(env)
end
def ensure_receiver(app_name, api_key)
- JSON.parse(@redis.get(app_name) || launch(app_name, api_key))
+ @redis.get(app_name) or
+ launch(app_name, api_key).tap {|url| @redis.set(app_name, url) }
end
def receiver_config(reply_key)
@@ -74,10 +75,8 @@ def launch(app_name, api_key)
{ :ps_env => receiver_config(reply_key) })
log(fn: "launch", app_name: app_name, reply_key: reply_key, at: "wait")
- @redis.blpop(reply_key, timeout: 5).tap {|receiver| @redis.set(app_name, receiver) }
+ @redis.blpop(reply_key, timeout: 5) or raise Error.new("Could not launch build process.")
end
- rescue Redis::TimeoutError
- raise Error.new("Could not launch build process.")
end
def api_key(env)
View
7 lib/sokoban/receiver.rb
@@ -3,7 +3,6 @@
require 'rack/response'
require 'rack/utils'
require 'redis'
-require 'json'
require 'time'
require 'scrolls'
@@ -68,9 +67,9 @@ def route(req_method, req_path)
def reply
host = UDPSocket.open { |s| s.connect("64.233.187.99", 1); s.addr.last }
- reply = JSON.unparse({:host => host, :port => ENV["PORT"]})
- log(fn: "reply", host: host, port: port)
- Redis.new(:url => ENV["REDIS_URL"]).lpush(ENV["REPLY_KEY"], reply)
+ url = "http://#{host}:#{ENV["PORT"]}/"
+ log(fn: "reply", url: url)
+ Redis.new(:url => ENV["REDIS_URL"]).lpush(ENV["REPLY_KEY"], url)
end
# ---------------------------------

0 comments on commit 2222bbc

Please sign in to comment.