Method: Amazon#in_cluster?

Defined in:
lib/cluster/infrastructures/amazon.rb,
lib/cluster/infrastructures/amazon.rb
more...

#in_cluster?Boolean

Returns:

  • (Boolean)
[View source]

244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
# File 'lib/cluster/infrastructures/amazon.rb', line 244

def in_cluster?
  return @cluster_check if @cluster_check

  check = false
  begin
    Timeout::timeout(1) do
      begin
        s = TCPSocket.new('169.254.169.254', 80)
        s.close
        check = true
      rescue Errno::ECONNREFUSED, Errno::EHOSTUNREACH
        # NOP
      end
    end
  rescue Timeout::Error
  end

  @@in_cluster = check
end