Sha256: cd9081a2a5acd4dc61ce5bda31d9593790c6e16b5ed534d582356e0286eec7ec

Contents?: true

Size: 1.16 KB

Versions: 1

Compression:

Stored size: 1.16 KB

Contents

#!/usr/bin/env ruby

require 'daemons'
require 'yaml'

require 'bitbot/bot'
require 'bitbot/database'

def usage
  puts "Usage: #{File.basename($0)} {start|stop|run} <path to config.yml>"
  exit 1
end

if ARGV.length < 2
  usage()
end

config_file = File.expand_path(ARGV.pop)

unless File.exist?(config_file)
  usage()
end

config = YAML::load(File.open(config_file))
unless File.exist?(File.dirname(config['data']['path']))
  puts "Data directory does not exist: #{File.dirname(config['data']['path'])}"
  exit 1
end

# Update the database file
Bitbot::Database.new(File.join(config['data']['path'], "bitbot.db")).upgrade_schema()

Daemons.run_proc('bitbot',
                 :hard_exit => true,
                 :backtrace => true,
                 :ontop => false,
                 :multiple => false,
                 :monitor => true,
                 :log_output => true) do

  bot = Bitbot::Bot.new(config)

  Thread.new do
    loop do
      begin
        bot.update_exchange_rates()
        bot.update_addresses()
      rescue => e
        puts "exception in loop addresses: #{e}"
        puts e.backtrace
      ensure
        sleep 60
      end
    end
  end

  bot.start
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
bitbot-0.0.1 bin/bitbot