lib/protobuf/cli.rb in protobuf-2.1.0 vs lib/protobuf/cli.rb in protobuf-2.1.1

- old
+ new

@@ -14,11 +14,11 @@ default_task :start desc 'start APP_FILE', 'Run the RPC server in the given mode, preloading the given APP_FILE. This is the default task.' option :host, :type => :string, :default => '127.0.0.1', :aliases => %w(-o), :desc => 'Host to bind.' - option :port, :type => :numeric, :default => 9595, :aliases => %w(-p), :desc => 'Port to bind.' + option :port, :type => :numeric, :default => 9399, :aliases => %w(-p), :desc => 'Master Port to bind.' option :backlog, :type => :numeric, :default => 100, :aliases => %w(-b), :desc => 'Backlog for listening socket when using Socket Server.' option :threshold, :type => :numeric, :default => 100, :aliases => %w(-t), :desc => 'Multi-threaded Socket Server cleanup threshold.' option :threads, :type => :numeric, :default => 5, :aliases => %w(-r), :desc => 'Number of worker threads to run. Only applicable in --zmq mode.' @@ -105,22 +105,18 @@ # Configure signal traps. # TODO add signal handling for hot-reloading the application. def configure_traps debug_say 'Configuring traps' - trap_block = proc { - ::Protobuf::Logger.info { 'RPC Server shutting down...' } - @start_aborted = true - @runner.stop - ::Protobuf::Logger.info { 'Shutdown complete' } - } - - debug_say 'Registering INT', :blue - trap(:INT, &trap_block) - debug_say 'Registering QUIT', :blue - trap(:QUIT, &trap_block) - debug_say 'Registering TERM', :blue - trap(:TERM, &trap_block) + [:INT, :QUIT, :TERM].each do |signal| + debug_say "Registering signal trap for #{signal}", :blue + trap(signal) do + ::Protobuf::Logger.info { 'RPC Server shutting down...' } + @start_aborted = true + @runner.stop + ::Protobuf::Logger.info { 'Shutdown complete' } + end + end end # Say something if we're in debug mode. def debug_say(message, color = :yellow) say(message, color) if options.debug?