From 0354765c0c77322ccc90c287b87e485ab22a5787 Mon Sep 17 00:00:00 2001 From: Nicolas Rodriguez Date: Thu, 7 Mar 2024 00:48:58 +0100 Subject: [PATCH] Allow user to define custom endpoint with env vars --- lib/derailed_benchmarks/load_tasks.rb | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/derailed_benchmarks/load_tasks.rb b/lib/derailed_benchmarks/load_tasks.rb index 834cc32..e84aae9 100644 --- a/lib/derailed_benchmarks/load_tasks.rb +++ b/lib/derailed_benchmarks/load_tasks.rb @@ -94,7 +94,8 @@ DERAILED_APP = DerailedBenchmarks.add_auth(Object.class_eval { remove_const(:DERAILED_APP) }) if server = ENV["USE_SERVER"] - @port = (3000..3900).to_a.sample + @host = ENV.fetch("HTTP_HOST") { "localhost" } + @port = ENV.fetch("HTTP_PORT") { (3000..3900).to_a.sample } puts "Port: #{ @port.inspect }" puts "Server: #{ server.inspect }" thread = Thread.new do @@ -103,7 +104,7 @@ sleep 1 def call_app(path = File.join("/", PATH_TO_HIT)) - cmd = "curl #{CURL_HTTP_HEADER_ARGS} 'http://localhost:#{@port}#{path}' -s --fail 2>&1" + cmd = "curl #{CURL_HTTP_HEADER_ARGS} 'http://#{@host}:#{@port}#{path}' -s --fail 2>&1" response = `#{cmd}` unless $?.success? STDERR.puts "Couldn't call app."