Files
fn-serverless/worker.rb
Travis 2a2cf3a3d6 Added IronCache (not used yet).
Using copy of reverse proxy so can get error response.
2012-12-31 16:20:45 -08:00

36 lines
963 B
Ruby

require 'rest'
require 'sinatra'
# The backend would do this part before execute the worker
########################################################
rest = Rest::Client.new
rest.logger.level = Logger::DEBUG
public_dns = rest.get("http://169.254.169.254/latest/meta-data/public-hostname").body
puts "public dns name: #{public_dns}"
port = rand(50000..55000)
puts "port: #{port}"
response = rest.post(
# "http://localhost:8080/",
"http://router.irondns.info/?project_id=#{params[:project_id]}&token=#{params[:token]}",
headers: {"Iron-Router"=>"YES!"},
body: {"host"=>"routertest.irondns.info", "dest"=>"#{public_dns}:#{port}"})
puts "body:"
puts response.body
STDOUT.flush
# Now we start the actual worker
##################################################################3
ENV['PORT'] = port.to_s # for sinatra
my_app = Sinatra.new do
set :port, port
get('/') { "hi" }
get('/*') { "you passed in #{params[:splat].inspect}" }
end
my_app.run!