lib/pione/command/pione-task-worker.rb in pione-0.2.0 vs lib/pione/command/pione-task-worker.rb in pione-0.2.1
- old
+ new
@@ -19,40 +19,45 @@
pione-client or pione-broker.
BANNER
end
define_option do
- use Option::ChildProcessOption
+ use :color
+ use :debug
+ use :my_ip_address
+ use :no_parent
+ use :parent_front
- default :features, Model::Feature::EmptyFeature.new
-
- # --connection-id
- option('--connection-id=ID', 'set connection id') do |data, id|
- data[:connection_id] = id
+ define(:connection_id) do |item|
+ item.long = '--connection-id=ID'
+ item.desc = 'set connection id'
+ item.value = proc {|id| id}
end
- # --feature
- option('--features=FEATURES', 'set features') do |data, features|
- begin
- features = DocumentTransformer.new.apply(
- DocumentParser.new.feature_expr.parse(features)
- )
- data[:features] = features
- rescue Parslet::ParseFailed => e
- puts "invalid parameters: " + str
- Util::ErrorReport.print(e)
- abort
+ define(:features) do |item|
+ item.long = '--features=FEATURES'
+ item.desc = 'set features'
+ item.value = proc do |features|
+ begin
+ DocumentTransformer.new.apply(
+ DocumentParser.new.feature_expr.parse(features)
+ )
+ rescue Parslet::ParseFailed => e
+ puts "invalid parameters: " + str
+ Util::ErrorReport.print(e)
+ abort
+ end
end
end
- validate do |data|
+ validate do |option|
# check requisite options
- abort("error: no connection id") if data[:connection_id].nil?
+ abort("error: no connection id") if option[:connection_id].nil?
# get the parent front server
begin
- data[:parent_front].uuid
+ option[:parent_front].uuid
rescue => e
if Pione.debug_mode?
debug_message "pione-task-worker cannot get the parent front server: %s" % e
end
abort
@@ -125,11 +130,9 @@
# disconnect parent front
option[:parent_front].remove_task_worker_front(self, option[:connection_id])
# flag
@terminated = true
-
- super
rescue DRb::DRbConnError, DRb::ReplyReaderThreadError => e
ErrorReport.warn("Disconnected in termination process of task worker agent.", self, e, __FILE__, __LINE__)
rescue ThreadError => e
# tuple space may be closed
ErrorReport.warn("Failed in termination process of task worker agent.", self, e, __FILE__, __LINE__)