Sha256: 0f9685b579febcaf4ec08de76dba5006d8e41edd54cfc2ca0adac6a614a7c739

Contents?: true

Size: 852 Bytes

Versions: 19

Compression:

Stored size: 852 Bytes

Contents

name 'http responder'
always_start true

default[:host], default[:port] = Kurchatov::Config[:http_responder].to_s.split(":")

run_if do
  !!Kurchatov::Config[:http_responder]
end

helpers do
  @s_time = Time.now
  def json_info
    {
      :version => Kurchatov::VERSION,
      :uptime => (Time.now - @s_time).to_i,
      :monitor => monitor.inspect,
      :fqdn => Kurchatov::Config[:host],
      :app_name => 'kurchatov'
    }.to_json + "\n"
  end
end

run do
  @server ||= TCPServer.new(plugin.host, plugin.port)
  loop do
    client = @server.accept
    response = json_info
    client.gets
    headers = "HTTP/1.1 200 OK\r\n" +
      "Server: Kurchatov Ruby\r\n" +
      "Content-Length: #{response.bytesize}\r\n" +
      "Content-Type: application/json\r\n\r\n"
      client.print headers
      client.print response
      client.close
  end
end

Version data entries

19 entries across 19 versions & 1 rubygems

Version Path
kurchatov-0.3.8 lib/kurchatov/responders/http.rb
kurchatov-0.3.7 lib/kurchatov/responders/http.rb
kurchatov-0.3.6 lib/kurchatov/responders/http.rb
kurchatov-0.3.5 lib/kurchatov/responders/http.rb
kurchatov-0.3.4 lib/kurchatov/responders/http.rb
kurchatov-0.3.3 lib/kurchatov/responders/http.rb
kurchatov-0.3.2 lib/kurchatov/responders/http.rb
kurchatov-0.3.1 lib/kurchatov/responders/http.rb
kurchatov-0.3.0 lib/kurchatov/responders/http.rb
kurchatov-0.2.9 lib/kurchatov/responders/http.rb
kurchatov-0.2.8 lib/kurchatov/responders/http.rb
kurchatov-0.2.7 lib/kurchatov/responders/http.rb
kurchatov-0.2.6 lib/kurchatov/responders/http.rb
kurchatov-0.2.5 lib/kurchatov/responders/http.rb
kurchatov-0.2.4 lib/kurchatov/responders/http.rb
kurchatov-0.2.3 lib/kurchatov/responders/http.rb
kurchatov-0.2.2 lib/kurchatov/responders/http.rb
kurchatov-0.2.1 lib/kurchatov/responders/http.rb
kurchatov-0.2.0 lib/kurchatov/responders/http.rb