Sha256: af123fa331fbae4df3a5ddb7aee63c70eb9c9cab8d4fde7ec8778ac76d602dd0

Contents?: true

Size: 1.02 KB

Versions: 1

Compression:

Stored size: 1.02 KB

Contents

#!/usr/bin/env ruby
require 'thor'
require 'tapyrus'
require 'daemon_spawn'

class TapyrusDaemon < DaemonSpawn::Base

  def start(args)
    puts "Tapyrusrb daemon start : #{Time.now}"
    conf = Tapyrus::Node::Configuration.new(network: args.first[:network])
    node = Tapyrus::Node::SPV.new(conf)
    node.run
  end

end

class Tapyrusrbd < Thor

  class_option :network, aliases: '-n', default: :mainnet

  desc 'start', 'start tapyrusrb daemon.'
  def start
    network = options['network'] ? options['network'].to_sym : :mainnet
    Tapyrus.chain_params = network
    FileUtils.mkdir_p(Tapyrus.base_dir)
    execute_daemon(['start', network: network])
  end

  private

  def execute_daemon(cmd_args)
    TapyrusDaemon.spawn!({working_dir: Tapyrus.base_dir,
                          log_file: "#{Tapyrus.base_dir}/log/tapyrusrbd.log",
                          pid_file: "#{Tapyrus.base_dir}/tapyrusrbd.pid",
                          sync_log: true,
                          singleton: true}, cmd_args)
  end

end

Tapyrusrbd.start(ARGV)

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
tapyrus-0.1.0 exe/tapyrusrbd