Class: DRbQS::Setting::Node
Constant Summary collapse
- LOG_PREFIX_DEFAULT =
'drbqs_node'
Constants included from Misc
Instance Attribute Summary
Attributes inherited from Base
Instance Method Summary collapse
- #exec(io = nil) ⇒ Object
-
#initialize ⇒ Node
constructor
A new instance of Node.
-
#parse! ⇒ Object
If there are invalid arguments, this method raises an error.
Methods inherited from Base
#clone, #string_for_shell, #value
Methods included from Misc
create_logger, create_uri, output_error, process_running_normally?, random_key, time_to_history_string, time_to_history_string2, uri_drbunix
Constructor Details
#initialize ⇒ Node
Returns a new instance of Node.
6 7 8 9 10 11 12 13 14 15 16 17 |
# File 'lib/drbqs/setting/node.rb', line 6 def initialize super(:all_keys_defined => true, :log_level => true, :daemon => true) do register_key(:load, :check => [:>, 0], :add => true) register_key(:process, :check => 1, :default => [1]) register_key(:group, :add => true) register_key(:loadavg, :check => 1) register_key(:log_prefix, :check => 1, :default => [LOG_PREFIX_DEFAULT]) register_key(:log_stdout, :bool => true) register_key(:connect, :check => 1) set_argument_condition(:==, 1) end end |
Instance Method Details
#exec(io = nil) ⇒ Object
71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 |
# File 'lib/drbqs/setting/node.rb', line 71 def exec(io = nil) if @__daemon__ fork do exec_as_daemon end return true end @options[:load].each do |path| io.puts "load #{path}" if io unless File.exist?(path) raise DRbQS::Setting::InvalidArgument, "#{path} does not exist." end load path end if io io.puts "PID: #{Process.pid}" io.puts "Connect to #{@uri}" io.puts "Execute #{@process_num} processes" end exec_node = DRbQS::Execution::ExecuteNode.new(@uri, @options[:log_prefix], @options[:log_level], @options[:node_opts]) exec_node.execute(@process_num) true end |
#parse! ⇒ Object
If there are invalid arguments, this method raises an error.
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/drbqs/setting/node.rb', line 29 def parse! super parse_load parse_group parse_loadavg if !get(:log_stdout) @options[:log_prefix] = get_first(:log_prefix) do |val| str = val.to_s str += 'out' if /\/$/ =~ str str end end @process_num = get_first(:process) @uri = get_argument[0] end |