Class: Crono::CLI

Inherits:
Object
  • Object
show all
Includes:
Logging, Singleton
Defined in:
lib/crono/cli.rb

Overview

Crono::CLI - The main class for the crono daemon exacutable ‘bin/crono`

Constant Summary collapse

COMMANDS =
%w(start stop restart run zap reload status)

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Logging

#logfile=, #logger

Constructor Details

#initializeCLI

Returns a new instance of CLI.



16
17
18
19
# File 'lib/crono/cli.rb', line 16

def initialize
  self.config = Config.new
  Crono.scheduler = Scheduler.new
end

Instance Attribute Details

#configObject

Returns the value of attribute config.



14
15
16
# File 'lib/crono/cli.rb', line 14

def config
  @config
end

Instance Method Details

#runObject



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

def run
  parse_options(ARGV)
  parse_command(ARGV)

  setup_log 

  write_pid unless config.daemonize
  load_rails
  Cronotab.process(File.expand_path(config.cronotab))
  print_banner

  unless have_jobs?
    logger.error "You have no jobs in you cronotab file #{config.cronotab}"
    return
  end

  if config.daemonize
    start_working_loop_in_daemon
  else
    start_working_loop
  end
end