Class: LoopDance::Controller
- Inherits:
-
DaemonController
- Object
- DaemonController
- LoopDance::Controller
- Defined in:
- lib/loop_dance/controller.rb
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.log_file ⇒ Object
26 27 28 |
# File 'lib/loop_dance/controller.rb', line 26 def log_file dancer.pid_file.gsub '.pid', '.log' end |
.new(dancer) ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/loop_dance/controller.rb', line 10 def new( dancer ) self.dancer = dancer h = { :identifier => dancer.name, :daemonize_for_me => true, :start_command => start_command, :ping_command => lambda { true }, :pid_file => dancer.pid_file, :log_file => log_file, :start_timeout => dancer.start_timeout, :stop_timeout => dancer.stop_timeout, :log_file_activity_timeout => dancer.log_file_activity_timeout } super h end |
.start_command ⇒ Object
30 31 32 33 34 35 36 37 |
# File 'lib/loop_dance/controller.rb', line 30 def start_command if defined? Rails "rails runner -e #{Rails.env} '#{dancer}.dance' 2>&1 >>#{log_file}" else "rails runner '#{dancer}.dance' 2>&1 >>#{log_file}" end end |
Instance Method Details
#safely_restart ⇒ Object
52 53 54 55 56 57 58 59 60 61 62 63 64 65 |
# File 'lib/loop_dance/controller.rb', line 52 def safely_restart dancer.log "Retarting.. (#{@start_command})" if running? dancer.log "Dancer is already running, stop" stop dancer.log "Start" start else start dancer.log "Started" end rescue => exception # DaemonController::StartTimeout log_exception exception end |
#safely_start ⇒ Object
40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/loop_dance/controller.rb', line 40 def safely_start dancer.log "Starting.. (#{@start_command})" if running? dancer.log "Dancer is already running" else start dancer.log "Started" end rescue => exception # DaemonController::StartTimeout log_exception exception end |
#safely_stop ⇒ Object
67 68 69 70 71 72 |
# File 'lib/loop_dance/controller.rb', line 67 def safely_stop dancer.log "Stopping.." stop if running? rescue => exception # DaemonController::StartTimeout log_exception exception end |