bin/drbqs-server in drbqs-0.0.12 vs bin/drbqs-server in drbqs-0.0.13
- old
+ new
@@ -1,11 +1,11 @@
#!/usr/bin/env ruby
require 'drbqs'
require 'optparse'
-Version = '0.0.12'
+Version = DRbQS::VERSION
help_message =<<HELP
Usage: #{File.basename(__FILE__)} <definition.rb> [other files ...] [options ...]
#{File.basename(__FILE__)} <definition.rb> [other files ...] [options ...] -- [server options ...]
Start DRbQS server of definition files.
@@ -17,10 +17,11 @@
:command_type => :server_start,
:acl => DRbQS::Config.get_acl_file
}
test_opts = {}
+execute_node_number = nil
command_argv, server_argv = DRbQS::Manage.split_arguments(ARGV)
begin
OptionParser.new(help_message) do |opt|
@@ -57,10 +58,13 @@
$DEBUG = true
end
opt.on('--test STR', String, 'Execute test.') do |v|
options[:command_type] = "test_#{v}"
end
+ opt.on('--execute-node NUM', Integer, 'Execute nodes.') do |v|
+ execute_node_number = v
+ end
opt.parse!(command_argv)
end
rescue OptionParser::InvalidOption
$stderr.print <<MES
error: Invalid Option
@@ -82,14 +86,35 @@
command_argv.each do |path|
puts "load #{path}"
load path
end
+WAIT_SERVER_TIME = 0.3
+NODE_INTERVAL_TIME = 1
+
DRbQS.parse_option(server_argv)
case options[:command_type]
when /^test/
s = options[:command_type].split('_')[1].split(',')
type = s[0].intern
DRbQS.test_server(options, type, s[1..-1], test_opts)
else
- DRbQS.start_server(options)
+ if execute_node_number
+ fork do
+ DRbQS.start_server(options)
+ end
+ uri = "druby://:#{options[:port] || DRbQS::ROOT_DEFAULT_PORT}"
+ manage = DRbQS::Manage.new
+ begin
+ sleep(WAIT_SERVER_TIME)
+ end while !manage.get_status(uri)
+ node_log_file = nil
+ unless IO === options[:log_file]
+ node_log_file = FileName.create(options[:log_file], :add => :always, :position => :middle, :delimiter => '', :format => "_node_%02d")
+ end
+ exec_node = DRbQS::ExecuteNode.new(uri, node_log_file, options[:log_level])
+ exec_node.execute(execute_node_number, NODE_INTERVAL_TIME)
+ exec_node.wait
+ else
+ DRbQS.start_server(options)
+ end
end