Class: Shoryuken::Later::CLI

Inherits:
Object
  • Object
show all
Includes:
Util, Singleton
Defined in:
lib/shoryuken/later/cli.rb

Instance Method Summary collapse

Instance Method Details

#run(args) ⇒ Object



19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/shoryuken/later/cli.rb', line 19

def run(args)
  @self_read, @self_write = IO.pipe

  %w[INT TERM USR1 USR2].each do |sig|
    trap sig do
      @self_write.puts(sig)
    end
  end

  setup_options(args) do |cli_options|
    # this needs to happen before configuration is parsed, since it may depend on Rails env
    load_rails if cli_options[:rails]
  end
  initialize_logger
  require_workers
  validate!
  daemonize
  write_pid
  
  Shoryuken::Logging.with_context '[later]' do
    logger.info 'Starting'
    start
  end
end