Class: DispatchRider::Command

Inherits:
Object
  • Object
show all
Defined in:
lib/dispatch-rider/command.rb

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Command

Returns a new instance of Command.



8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/dispatch-rider/command.rb', line 8

def initialize(options = {})
  @app_home = Pathname.new(Dir.getwd)
  @options = {
    :log_output => true,
    :dir_mode => :normal,
    :log_dir => (@app_home + "log").to_s,
    :dir => (@app_home + "log").to_s,
    :multiple => false,
    :monitor => false,
    :identifier => 0,
  }.merge(options)
end

Instance Method Details

#run(args, &block) ⇒ Object



21
22
23
24
25
26
27
28
29
30
31
# File 'lib/dispatch-rider/command.rb', line 21

def run(args, &block)
  process_args(args)

  process_name = "dispatch_rider.#{@options[:identifier]}"
  Daemons.run_proc(process_name, @options) do
    $0 = File.join(@options[:prefix], process_name) if @options[:prefix]
    Dir.chdir(@app_home.to_s) do
      block.call
    end
  end
end