Class: Guard::RackRunner

Inherits:
Object
  • Object
show all
Defined in:
lib/guard/rack/runner.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options) ⇒ RackRunner

Returns a new instance of RackRunner.



10
11
12
# File 'lib/guard/rack/runner.rb', line 10

def initialize(options)
  @options = options
end

Instance Attribute Details

#optionsObject (readonly)

Returns the value of attribute options.



8
9
10
# File 'lib/guard/rack/runner.rb', line 8

def options
  @options
end

#pidObject (readonly)

Returns the value of attribute pid.



8
9
10
# File 'lib/guard/rack/runner.rb', line 8

def pid
  @pid
end

Instance Method Details

#restartObject



34
35
36
# File 'lib/guard/rack/runner.rb', line 34

def restart
  stop && start
end

#startObject



14
15
16
17
18
# File 'lib/guard/rack/runner.rb', line 14

def start
  kill_unmanaged_pid! if options[:force_run]
  @pid = run_rack_command!
  true
end

#stopObject



20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/guard/rack/runner.rb', line 20

def stop
  # Rely on kill_unmanaged_pid if there's no pid
  return true unless @pid

  exitstatus = kill(@pid)
  @pid = nil
  if exitstatus && exitstatus != 0
    UI.info "Rackup exited with non-zero exit status (#{exitstatus}) whilst trying to stop."
    return false
  end

  true
end