Class: UpstartUnicornLauncher

Inherits:
Object
  • Object
show all
Defined in:
lib/upstart_unicorn_launcher.rb,
lib/upstart_unicorn_launcher/version.rb

Constant Summary collapse

VERSION =
"0.0.4"

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(command, options = {}) ⇒ UpstartUnicornLauncher

Returns a new instance of UpstartUnicornLauncher.



6
7
8
9
10
11
12
# File 'lib/upstart_unicorn_launcher.rb', line 6

def initialize(command, options = {})
  self.command = command
  self.pidfile = File.expand_path(options[:pidfile] || 'unicorn.pid')
  self.startup_period = options[:startup] || 60
  self.tick_period = options[:tick] || 0.1
  self.verbose = options[:verbose] || false
end

Instance Attribute Details

#commandObject

Returns the value of attribute command.



4
5
6
# File 'lib/upstart_unicorn_launcher.rb', line 4

def command
  @command
end

#pidfileObject

Returns the value of attribute pidfile.



4
5
6
# File 'lib/upstart_unicorn_launcher.rb', line 4

def pidfile
  @pidfile
end

#restartingObject

Returns the value of attribute restarting.



4
5
6
# File 'lib/upstart_unicorn_launcher.rb', line 4

def restarting
  @restarting
end

#startup_periodObject

Returns the value of attribute startup_period.



4
5
6
# File 'lib/upstart_unicorn_launcher.rb', line 4

def startup_period
  @startup_period
end

#tick_periodObject

Returns the value of attribute tick_period.



4
5
6
# File 'lib/upstart_unicorn_launcher.rb', line 4

def tick_period
  @tick_period
end

#verboseObject

Returns the value of attribute verbose.



4
5
6
# File 'lib/upstart_unicorn_launcher.rb', line 4

def verbose
  @verbose
end

Instance Method Details

#startObject



14
15
16
17
18
19
20
21
22
23
# File 'lib/upstart_unicorn_launcher.rb', line 14

def start
  debug "Starting server"
  restart_server_on :HUP
  quit_server_on :QUIT, :INT, :TERM
  forward_to_server :USR1, :USR2, :WINCH, :TTIN, :TTOU
  start_server
  loop do
    sleep 1
  end
end