Class: Rjob::CLI

Inherits:
Object
  • Object
show all
Defined in:
lib/rjob/cli.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeCLI

Returns a new instance of CLI.



9
10
11
12
13
# File 'lib/rjob/cli.rb', line 9

def initialize
  @use_rails = false
  @run_workers = false
  @requires = []
end

Class Method Details

.bootObject



7
# File 'lib/rjob/cli.rb', line 7

def self.boot; new.boot(ARGV); end

Instance Method Details

#boot(args) ⇒ Object



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/rjob/cli.rb', line 15

def boot(args)
  STDOUT.sync = true
  STDERR.sync = true

  parse_cli_args(args)

  if @use_rails
    require File.join(Dir.pwd, "config/environment")
  end

  @requires.each do |r|
    require r
  end

  run_workers if @run_workers
end

#run_workersObject



32
33
34
35
36
37
38
# File 'lib/rjob/cli.rb', line 32

def run_workers
  require "rjob"
  require "rjob/worker_process"

  worker = Rjob::WorkerProcess.new(Rjob::Context.instance)
  worker.run_forever
end