Class: RailsInstaller::WebServer::MongrelCluster

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

Overview

A web server driver for MongrelCluster.

Class Method Summary collapse

Methods inherited from RailsInstaller::WebServer

inherited, servers

Class Method Details

.start(installer, foreground) ⇒ Object



73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
# File 'lib/rails-installer/web-servers.rb', line 73

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['-N'] = installer.config['threads']
  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', 'cluster::configure'] + args_array
  installer.message "Configuring mongrel_cluster for #{installer.app_name.capitalize}"
  in_directory installer.install_directory do
    system(args_array.join(' '))
  end
  installer.message "Starting #{installer.app_name.capitalize} on port #{installer.config['port-number']}"
  in_directory installer.install_directory do
    system('mongrel_rails cluster::start')
  end
  
end

.stop(installer) ⇒ Object



97
98
99
100
101
102
# File 'lib/rails-installer/web-servers.rb', line 97

def self.stop(installer)
  installer.message "Stopping #{installer.app_name.capitalize}"
  in_directory installer.install_directory do
    system('mongrel_rails cluster::stop')
  end
end