Sha256: a5c0468f5cc437a8b9d0afc55c05f246351f19cd1001807747ae6d4a20e7dc78
Contents?: true
Size: 1.71 KB
Versions: 3
Compression:
Stored size: 1.71 KB
Contents
require 'socket' module DRbQS class SendCommand MAX_WAIT_TIME = 10 def initialize(message) @message = message end def get_hostname "Command of #{Socket.gethostname}" end private :get_hostname def send_exit_signal @message.write([:server, :exit_server, get_hostname]) end def get_status @message.write([:server, :request_status, get_hostname]) i = 0 loop do begin mes = @message.take([:status, String], 0) return mes[1] rescue Rinda::RequestExpiredError i += 1 if i > MAX_WAIT_TIME return nil end sleep(1) end end end end class Manage def self.split_arguments(argv, split = '--') if n = argv.index(split) [argv[0..(n - 1)], argv[(n + 1)..-1]] else [argv, []] end end def create_config Config.check_directory_create Config.save_sample end def command_client(access_uri) obj = DRbObject.new_with_uri(access_uri) DRbQS::SendCommand.new(obj[:message]) rescue DRb::DRbConnError $stderr.puts "Can not access #{access_uri}" nil end private :command_client def send_exit_signal(access_uri) if client = command_client(access_uri) client.send_exit_signal end end def get_status(access_uri) if client = command_client(access_uri) client.get_status end end def execute_over_ssh(dest, opts, command) ssh = DRbQS::SSHShell.new(dest, opts) ssh.start(command) end def get_ssh_environment(dest, opts) ssh = DRbQS::SSHShell.new(dest, opts) ssh.get_environment end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
drbqs-0.0.13 | lib/drbqs/manage.rb |
drbqs-0.0.12 | lib/drbqs/manage.rb |
drbqs-0.0.11 | lib/drbqs/manage.rb |