Class: Unicorn::HttpServer

Inherits:
Object
  • Object
show all
Defined in:
lib/unicorn-lockdown.rb

Instance Method Summary collapse

Instance Method Details

#_original_spawn_missing_workersObject



25
# File 'lib/unicorn-lockdown.rb', line 25

alias _original_spawn_missing_workers spawn_missing_workers

#proc_name(tag) ⇒ Object

Override the process name for the unicorn processes, both master and worker. This gives all applications a consistent prefix, which can be used to pkill processes by name instead of using pidfiles.



41
42
43
44
# File 'lib/unicorn-lockdown.rb', line 41

def proc_name(tag)
  ctx = self.class::START_CTX
  $0 = ["unicorn-#{Unicorn.app_name}-#{tag}"].concat(ctx[:argv]).join(' ')
end

#request_filename(pid) ⇒ Object

The file name in which to store request information. The /var/www/request-error-data/$app_name folder is accessable only to the user of the application.



20
21
22
# File 'lib/unicorn-lockdown.rb', line 20

def request_filename(pid)
  "/var/www/request-error-data/#{Unicorn.app_name}/#{pid}.txt"
end

#spawn_missing_workersObject

This is the master process, set the master pledge before spawning workers, because spawning workers will also need to be done at runtime.



29
30
31
32
33
34
35
# File 'lib/unicorn-lockdown.rb', line 29

def spawn_missing_workers
  if pledge = Unicorn.master_pledge
    Unicorn.master_pledge = nil
    Pledge.pledge(pledge, Unicorn.master_execpledge)
  end
  _original_spawn_missing_workers
end