class StompJob::Cli

Constants

Public Instance Methods

work() click to toggle source
# File lib/stomp_job/cli.rb, line 45
def work
  say BANNER
  say
  require_files if options['require']
  load_rails if options['rails']

  say "Starting Stomper with workers:"
  say pretty_print_workers, :yellow
  say

  Workers.listen!
end

Private Instance Methods

die(exception, debug_help=nil) click to toggle source
# File lib/stomp_job/cli.rb, line 77
def die(exception, debug_help=nil)
  say "StompJob encountered the following error and is quitting:\n\t#{exception.message}", :red
  say
  say debug_help, :red if debug_help

  exit 1
end
load_rails() click to toggle source
# File lib/stomp_job/cli.rb, line 69
def load_rails
  require './config/application'
  ::Rails.application.eager_load!
rescue Exception => e
  die(e, "Are you running this from a rails app?\nStompJob expects to be able to `require ./config/application`")
end
pretty_print_workers() click to toggle source
# File lib/stomp_job/cli.rb, line 85
def pretty_print_workers
  Workers.registered_workers.map{|worker| "\t#{worker.name}\n"}.join('')
end
require_files() click to toggle source
# File lib/stomp_job/cli.rb, line 61
def require_files
  options['require'].split(',').each do |require_file|
    require require_file
  end
rescue Exception => e
  die(e)
end