Sha256: 0e5cf4c71b8e0025fd7724fe1ba7ef976874c3c6c31827705343e0bf8aedcedc

Contents?: true

Size: 1.17 KB

Versions: 3

Compression:

Stored size: 1.17 KB

Contents

#!/usr/bin/env ruby

require 'rubygems'
require 'daemons'
require 'logger'
require File.dirname(__FILE__) + '/../lib/heartbeat-client'

begin
  puts "Using config in your home directory"
  @config = YAML.load(File.read("#{ENV['HOME']}/.heartbeat-client.yml"))
rescue Errno::ENOENT
  raise "heartbeat-client.yml expected in ~/.heartbeat-client.yml"
end

unless @config['apikey']
  puts "API Key not found!"
  exit
end

unless @config['endpoint']
  puts "Service Endpoint not found!"
  exit
end

version = "0.0"
begin
  file = File.open(File.dirname(__FILE__) + "/../VERSION", "rb")
  version = file.read
  puts "heartbeat-client #{version}"
rescue => e
  puts e.message
end

if ARGV and ARGV.size == 1
  Daemons.run_proc('heartbeat-client.rb', :dir => File.join('/tmp'), :monitor => true,
    :backtrace => true, :monitor => true) do
    Heartbeat.log = Logger.new('/tmp/heartbeat.log')
    count = 1
    loop do
      begin
        count += 1
        Heartbeat.create(@config, version, (count == 2))
        count = 0 if count == 3
      rescue => e
        puts e.message
      end
      GC.start
      sleep(30)
    end
  end
else
  puts "Please provide a command to hbc (start|stop|run)!"
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
heartbeat-client-0.6.0 bin/hbc
heartbeat-client-0.5.0 bin/hbc
heartbeat-client-0.4.4 bin/hbc