Class: RailsInstaller::WebServer::Mongrel

Inherits:
RailsInstaller::WebServer show all
Defined in:
lib/rails-installer/web-servers.rb

Overview

A web server plugin for Mongrel (mongrel.rubyforge.org).

Class Method Summary collapse

Methods inherited from RailsInstaller::WebServer

inherited, servers

Class Method Details

.pid_file(installer) ⇒ Object



66
67
68
# File 'lib/rails-installer/web-servers.rb', line 66

def self.pid_file(installer)
  File.join(installer.install_directory,'tmp','pid.txt')
end

.start(installer, foreground) ⇒ Object



33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# File 'lib/rails-installer/web-servers.rb', line 33

def self.start(installer, foreground)
  args = {}
  args['-p'] = installer.config['port-number']
  args['-a'] = installer.config['bind-address']
  args['-e'] = installer.config['rails-environment']
  args['-d'] = foreground
  args['-P'] = pid_file(installer)
  args['--prefix'] = installer.config['url-prefix']

  # Remove keys with nil values
  args.delete_if {|k,v| v==nil}

  args_array = args.to_a.flatten.map {|e| e.to_s}
  args_array = ['mongrel_rails', 'start', installer.install_directory] + args_array
  installer.message "Starting #{installer.app_name.capitalize} on port #{installer.config['port-number']}"
  in_directory installer.install_directory do
    system(args_array.join(' '))
  end
end

.stop(installer) ⇒ Object



53
54
55
56
57
58
59
60
61
62
63
64
# File 'lib/rails-installer/web-servers.rb', line 53

def self.stop(installer)
  args = {}
  args['-P'] = pid_file(installer)

  args_array = args.to_a.flatten.map {|e| e.to_s}
  args_array = ['mongrel_rails', 'stop', installer.install_directory] + args_array
  installer.message "Stopping #{installer.app_name.capitalize}"
  in_directory installer.install_directory do
    system(args_array.join(' '))
  end
  
end