DBDaemon/cdclient_daemon.rb
# Tries several times to connect to the webserver
Tries several times to connect to the webserver
Tries several times to connect to the webserver
def connect_to_webserver(drb_uri, options, web_server_uri)
  try_counter=0; try_max= 30
      loop do
        begin
          puts "#{Time.now} *** try connecting to : #{web_server_uri}"
          sleep(5+rand*2)
          RestClient.post web_server_uri+'/connectors', {:connector => {:service => options[:service], :uri => drb_uri, :uid => options[:uid], :prio => options[:prio]}}, :content_type => :json, :accept => :json
          puts "*** connection succesfully established"
      $stdout.flush 
          return true
        rescue => e
          try_counter=try_counter+1
          puts "Failed with error:#{e.message} and try number:#{try_counter}"
          if try_counter==try_max
            puts "Disconnected from Service: #{web_server_uri}"
      $stdout.flush 
            return false
          end
        end
      end
end
def connect_to_webserver ( drb_uri , options , web_server_uri ) try_counter = 0 ; try_max = 30 loop do begin puts "#{Time.now} *** try connecting to : #{web_server_uri}" sleep ( 5 + rand * 2 ) RestClient . post web_server_uri + '/connectors' , { :connector => { :service => options [ :service ] , :uri => drb_uri , :uid => options [ :uid ] , :prio => options [ :prio ] } } , :content_type => :json , :accept => :json puts "*** connection succesfully established" $stdout . flush return true rescue => e try_counter = try_counter + 1 puts "Failed with error:#{e.message} and try number:#{try_counter}" if try_counter == try_max puts "Disconnected from Service: #{web_server_uri}" $stdout . flush return false end end end end
Tries several times to connect to the webserver
Tries several times to connect to the webserver
drb_uri
<not_specific>
options
<not_specific>
web_server_uri
<not_specific>