diff --git a/register_host.rb b/register_host.rb index f12886bce..9ccd2d215 100644 --- a/register_host.rb +++ b/register_host.rb @@ -1,38 +1,26 @@ require 'rest' require 'uber_config' -@config = UberConfig.load('config_development.yml') +@config = UberConfig.load(file: 'config_development.json') rest = Rest::Client.new rest.logger.level = Logger::DEBUG -project_id = @config[:project_id] -token = @config[:token] +project_id = @config[:iron][:project_id] +token = @config[:iron][:token] # host name -host_name = @config[:host_name] || "routertest.irondns.info" +host_name = @config[:iron][:host_name] || "routertest.irondns.info" # which worker to run -code_name = @config[:code_name] || "sinatra" +code_name = @config[:iron][:code_name] || "sinatra" response = rest.post( # "http://localhost:8080/", "http://router.irondns.info/?project_id=#{project_id}&token=#{token}&code_name=#{code_name}", headers: {"Iron-Router"=>"register"}, - body: {"host"=>host_name, "code"=>code_name) -puts "body:" + body: {"host"=>host_name, "code"=>code_name} + ) +puts "response body:" puts response.body puts "\n\n=======\n\n" -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! - diff --git a/src/router/router.go b/src/router/router.go index 3169a365a..d65b36867 100644 --- a/src/router/router.go +++ b/src/router/router.go @@ -24,6 +24,7 @@ import ( "time" "runtime" "flag" + "io/ioutil" ) var config struct { @@ -186,6 +187,9 @@ func ProxyFunc(w http.ResponseWriter, req *http.Request) { func AddWorker(w http.ResponseWriter, req *http.Request) { log.Println("AddWorker called!") + s, err := ioutil.ReadAll(req.Body) + fmt.Println("req.body:", err, s) + // get project id and token projectId := req.FormValue("project_id") token := req.FormValue("token")