Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Oh fun, redis blpop returns a tuple.

  • Loading branch information...
commit 1afb9acf602106aceeefe8f3caf3a81f2830288a 1 parent 50d7313
Phil Hagelberg authored
Showing with 10 additions and 5 deletions.
  1. +8 −3 lib/sokoban.rb
  2. +2 −2 lib/sokoban/receiver.rb
11 lib/sokoban.rb
View
@@ -55,8 +55,7 @@ def call(env)
end
def ensure_receiver(app_name, api_key)
- @redis.get(app_name) or
- launch(app_name, api_key).tap {|url| @redis.set(app_name, url) }
+ @redis.get(app_name) or launch(app_name, api_key)
end
def receiver_config(reply_key)
@@ -75,7 +74,13 @@ 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: 30) or raise Error.new("Could not launch build process.")
+ _, url = @redis.blpop(reply_key, timeout: 30)
+ if url
+ @redis.set(app_name, url)
+ return url
+ else
+ raise Error.new("Could not launch build process.")
+ end
end
end
4 lib/sokoban/receiver.rb
View
@@ -30,7 +30,7 @@ def initialize(repo_url)
bundle = File.join("/tmp", "repo.bundle")
@repo_dir = File.join("/tmp", "repo.git")
- log(at: "clone") do
+ log(action: "fetch") do
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}")
@@ -67,7 +67,7 @@ def route(req_method, req_path)
def reply
host = UDPSocket.open { |s| s.connect("64.233.187.99", 1); s.addr.last }
- url = "http://#{host}:#{ENV["PORT"]}/"
+ url = "http://#{host}:#{ENV["PORT"]}"
log(fn: "reply", url: url)
Redis.new(:url => ENV["REDIS_URL"]).lpush(ENV["REPLY_KEY"], url)
end
Please sign in to comment.
Something went wrong with that request. Please try again.