mongrel_cluster 0.1.1 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/COPYING +504 -18
- data/LICENSE +504 -18
- data/README +17 -10
- data/Rakefile +17 -2
- data/bin/mongrel_cluster_ctl +62 -0
- data/lib/mongrel_cluster/init.rb +34 -13
- data/lib/mongrel_cluster/recipes.rb +38 -15
- data/resources/mongrel_cluster +34 -0
- metadata +8 -6
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
# Copyright (c) 2006 Bradley Taylor, bradley@railsmachine.com
|
|
3
|
+
|
|
4
|
+
require 'optparse'
|
|
5
|
+
|
|
6
|
+
def run(command, verbose)
|
|
7
|
+
Dir.chdir @options[:conf_path] do
|
|
8
|
+
Dir.glob("*.yml").each do |config|
|
|
9
|
+
cmd = "mongrel_rails cluster::#{command} -c #{config}"
|
|
10
|
+
cmd += " -v" if verbose
|
|
11
|
+
puts cmd if verbose
|
|
12
|
+
output = `#{cmd}`
|
|
13
|
+
puts output if verbose
|
|
14
|
+
puts "mongrel_rails cluster::#{command} returned an error." unless $?.success?
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
@options = {}
|
|
20
|
+
@options[:conf_path] = "/etc/mongrel_cluster"
|
|
21
|
+
@options[:verbose] = false
|
|
22
|
+
|
|
23
|
+
OptionParser.new do |opts|
|
|
24
|
+
opts.banner = "Usage: #{$0} (start|stop|restart) [options]"
|
|
25
|
+
|
|
26
|
+
opts.on("-c", "--conf_path PATH", "Path to mongrel_cluster configuration files") { |value| @options[:conf_path] = value }
|
|
27
|
+
opts.on('-v', '--verbose', "Print all called commands and output.") { |value| @options[:verbose] = value }
|
|
28
|
+
|
|
29
|
+
if ARGV.empty?
|
|
30
|
+
puts opts
|
|
31
|
+
exit
|
|
32
|
+
else
|
|
33
|
+
@cmd = opts.parse!(ARGV)
|
|
34
|
+
if @cmd.nil?
|
|
35
|
+
puts opts
|
|
36
|
+
exit
|
|
37
|
+
end
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
if @options[:conf_path] == nil && !File.directory?(@options[:conf_path])
|
|
43
|
+
puts "Invalid path to mongrel_cluster configuration files: #{@options[:conf_path]}"
|
|
44
|
+
exit
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
case @cmd[0]
|
|
48
|
+
when "start":
|
|
49
|
+
puts "Starting all mongrel_clusters..."
|
|
50
|
+
run "start", @options[:verbose]
|
|
51
|
+
when "stop":
|
|
52
|
+
puts "Stopping all mongrel_clusters..."
|
|
53
|
+
run "stop", @options[:verbose]
|
|
54
|
+
when "restart":
|
|
55
|
+
puts "Restarting all mongrel_clusters..."
|
|
56
|
+
run "stop", @options[:verbose]
|
|
57
|
+
run "start", @options[:verbose]
|
|
58
|
+
else
|
|
59
|
+
puts "Unknown command."
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
exit
|
data/lib/mongrel_cluster/init.rb
CHANGED
|
@@ -8,7 +8,10 @@ module Cluster
|
|
|
8
8
|
include Mongrel::Command::Base
|
|
9
9
|
|
|
10
10
|
def configure
|
|
11
|
-
options [
|
|
11
|
+
options [
|
|
12
|
+
['-C', '--config PATH', "Path to configuration file", :@config_file, "config/mongrel_cluster.yml"],
|
|
13
|
+
['-v', '--verbose', "Print all called commands and output.", :@verbose, false]
|
|
14
|
+
]
|
|
12
15
|
end
|
|
13
16
|
|
|
14
17
|
def validate
|
|
@@ -44,10 +47,16 @@ module Cluster
|
|
|
44
47
|
argv << "-n #{@options["num_procs"]}" if @options["num_procs"]
|
|
45
48
|
argv << "-B" if @options["debug"]
|
|
46
49
|
argv << "-S #{@options["config_script"]}" if @options["config_script"]
|
|
50
|
+
argv << "--user #{@options["user"]}" if @options["user"]
|
|
51
|
+
argv << "--group #{@options["group"]}" if @options["group"]
|
|
47
52
|
cmd = argv.join " "
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
53
|
+
|
|
54
|
+
puts cmd if @verbose
|
|
55
|
+
output = `#{cmd}`
|
|
56
|
+
unless $?.success?
|
|
57
|
+
puts cmd unless @verbose
|
|
58
|
+
puts output
|
|
59
|
+
end
|
|
51
60
|
end
|
|
52
61
|
end
|
|
53
62
|
end
|
|
@@ -58,7 +67,8 @@ module Cluster
|
|
|
58
67
|
def configure
|
|
59
68
|
options [
|
|
60
69
|
['-C', '--config PATH', "Path to config file", :@config_file, "config/mongrel_cluster.yml"],
|
|
61
|
-
['-f', '--force', "Force the shutdown.", :@force, false]
|
|
70
|
+
['-f', '--force', "Force the shutdown.", :@force, false],
|
|
71
|
+
['-v', '--verbose', "Print all called commands and output.", :@verbose, false]
|
|
62
72
|
]
|
|
63
73
|
end
|
|
64
74
|
|
|
@@ -87,9 +97,12 @@ module Cluster
|
|
|
87
97
|
argv << "-c #{@options["cwd"]}" if @options["cwd"]
|
|
88
98
|
argv << "-f" if @force
|
|
89
99
|
cmd = argv.join " "
|
|
90
|
-
puts cmd
|
|
91
|
-
|
|
92
|
-
|
|
100
|
+
puts cmd if @verbose
|
|
101
|
+
output = `#{cmd}`
|
|
102
|
+
unless $?.success?
|
|
103
|
+
puts cmd unless @verbose
|
|
104
|
+
puts output
|
|
105
|
+
end
|
|
93
106
|
end
|
|
94
107
|
end
|
|
95
108
|
end
|
|
@@ -100,7 +113,8 @@ module Cluster
|
|
|
100
113
|
def configure
|
|
101
114
|
options [
|
|
102
115
|
['-C', '--config PATH', "Path to config file", :@config_file, "config/mongrel_cluster.yml"],
|
|
103
|
-
['-s', '--soft', "Do a soft restart rather than a process exit restart", :@soft, false]
|
|
116
|
+
['-s', '--soft', "Do a soft restart rather than a process exit restart", :@soft, false],
|
|
117
|
+
['-v', '--verbose', "Print all called commands and output.", :@verbose, false]
|
|
104
118
|
]
|
|
105
119
|
end
|
|
106
120
|
|
|
@@ -128,9 +142,12 @@ module Cluster
|
|
|
128
142
|
argv << "-c #{@options["cwd"]}" if @options["cwd"]
|
|
129
143
|
argv << "-s" if @soft
|
|
130
144
|
cmd = argv.join " "
|
|
131
|
-
puts cmd
|
|
132
|
-
|
|
133
|
-
|
|
145
|
+
puts cmd if @verbose
|
|
146
|
+
output = `#{cmd}`
|
|
147
|
+
unless $?.success?
|
|
148
|
+
puts cmd unless @verbose
|
|
149
|
+
puts output
|
|
150
|
+
end
|
|
134
151
|
end
|
|
135
152
|
end
|
|
136
153
|
end
|
|
@@ -153,7 +170,9 @@ module Cluster
|
|
|
153
170
|
['-B', '--debug', "Enable debugging mode", :@debug, nil],
|
|
154
171
|
['-S', '--script PATH', "Load the given file as an extra config script.", :@config_script, nil],
|
|
155
172
|
['-N', '--num-servers INT', "Number of Mongrel servers", :@servers, 2],
|
|
156
|
-
['-C', '--config PATH', "Path to config file", :@config_file, "config/mongrel_cluster.yml"]
|
|
173
|
+
['-C', '--config PATH', "Path to config file", :@config_file, "config/mongrel_cluster.yml"],
|
|
174
|
+
['', '--user USER', "User to run as", :@user, nil],
|
|
175
|
+
['', '--group GROUP', "Group to run as", :@group, nil]
|
|
157
176
|
]
|
|
158
177
|
end
|
|
159
178
|
|
|
@@ -183,6 +202,8 @@ module Cluster
|
|
|
183
202
|
@options["mime_map"] = @mime_map if @mime_map
|
|
184
203
|
@options["config_script"] = @config_script if @config_script
|
|
185
204
|
@options["cwd"] = @cwd if @cwd
|
|
205
|
+
@options["user"] = @user if @user
|
|
206
|
+
@options["group"] = @group if @group
|
|
186
207
|
|
|
187
208
|
puts "Writing configuration file to #{@config_file}."
|
|
188
209
|
File.open(@config_file,"w") {|f| f.write(@options.to_yaml)}
|
|
@@ -1,41 +1,60 @@
|
|
|
1
1
|
Capistrano.configuration(:must_exist).load do
|
|
2
|
-
set :mongrel_servers,
|
|
3
|
-
set :mongrel_port,
|
|
2
|
+
set :mongrel_servers, 2
|
|
3
|
+
set :mongrel_port, 8000
|
|
4
4
|
set :mongrel_address, "127.0.0.1"
|
|
5
5
|
set :mongrel_environment, "production"
|
|
6
|
-
set
|
|
6
|
+
set :mongrel_conf, nil
|
|
7
|
+
set :mongrel_user, nil
|
|
8
|
+
set :mongrel_group, nil
|
|
7
9
|
|
|
8
10
|
desc <<-DESC
|
|
9
11
|
Configure Mongrel processes on the app server. This uses the :use_sudo
|
|
10
|
-
variable to determine whether to use sudo or not.
|
|
12
|
+
variable to determine whether to use sudo or not. By default, :use_sudo is
|
|
13
|
+
set to true.
|
|
11
14
|
DESC
|
|
12
15
|
task :configure_mongrel_cluster, :roles => :app do
|
|
13
|
-
|
|
14
|
-
|
|
16
|
+
set_mongrel_conf
|
|
17
|
+
|
|
18
|
+
argv = []
|
|
19
|
+
argv << "mongrel_rails cluster::configure"
|
|
20
|
+
argv << "-N #{mongrel_servers.to_s}"
|
|
21
|
+
argv << "-p #{mongrel_port.to_s}"
|
|
22
|
+
argv << "-e #{mongrel_environment}"
|
|
23
|
+
argv << "-a #{mongrel_address}"
|
|
24
|
+
argv << "-c #{current_path}"
|
|
25
|
+
argv << "-C #{mongrel_conf}"
|
|
26
|
+
argv << "--user #{mongrel_user}" if mongrel_user
|
|
27
|
+
argv << "--group #{mongrel_group}" if mongrel_group
|
|
28
|
+
cmd = argv.join " "
|
|
29
|
+
send(run_method, cmd)
|
|
15
30
|
end
|
|
16
31
|
|
|
17
32
|
desc <<-DESC
|
|
18
|
-
Start Mongrel processes on the app server.
|
|
19
|
-
|
|
33
|
+
Start Mongrel processes on the app server. This uses the :use_sudo variable to determine whether to use sudo or not. By default, :use_sudo is
|
|
34
|
+
set to true.
|
|
20
35
|
DESC
|
|
21
36
|
task :start_mongrel_cluster , :roles => :app do
|
|
22
|
-
|
|
37
|
+
set_mongrel_conf
|
|
38
|
+
send(run_method, "mongrel_rails cluster::start -C #{mongrel_conf}")
|
|
23
39
|
end
|
|
24
40
|
|
|
25
41
|
desc <<-DESC
|
|
26
|
-
Restart the Mongrel processes on the app server. This uses the :use_sudo
|
|
27
|
-
variable to determine whether to use sudo or not.
|
|
42
|
+
Restart the Mongrel processes on the app server by starting and stopping the cluster. This uses the :use_sudo
|
|
43
|
+
variable to determine whether to use sudo or not. By default, :use_sudo is set to true.
|
|
28
44
|
DESC
|
|
29
45
|
task :restart_mongrel_cluster , :roles => :app do
|
|
30
|
-
|
|
46
|
+
stop_mongrel_cluster
|
|
47
|
+
start_mongrel_cluster
|
|
31
48
|
end
|
|
32
49
|
|
|
33
50
|
desc <<-DESC
|
|
34
|
-
Stop the Mongrel processes on the app server.
|
|
35
|
-
variable to determine whether to use sudo or not.
|
|
51
|
+
Stop the Mongrel processes on the app server. This uses the :use_sudo
|
|
52
|
+
variable to determine whether to use sudo or not. By default, :use_sudo is
|
|
53
|
+
set to true.
|
|
36
54
|
DESC
|
|
37
55
|
task :stop_mongrel_cluster , :roles => :app do
|
|
38
|
-
|
|
56
|
+
set_mongrel_conf
|
|
57
|
+
send(run_method, "mongrel_rails cluster::stop -C #{mongrel_conf}")
|
|
39
58
|
end
|
|
40
59
|
|
|
41
60
|
desc <<-DESC
|
|
@@ -51,5 +70,9 @@ Capistrano.configuration(:must_exist).load do
|
|
|
51
70
|
task :spinner, :roles => :app do
|
|
52
71
|
start_mongrel_cluster
|
|
53
72
|
end
|
|
73
|
+
|
|
74
|
+
def set_mongrel_conf
|
|
75
|
+
set :mongrel_conf, "/etc/mongrel_cluster/#{application}.conf" unless mongrel_conf
|
|
76
|
+
end
|
|
54
77
|
|
|
55
78
|
end
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
#!/bin/bash
|
|
2
|
+
#
|
|
3
|
+
# Copyright (c) 2006 Bradley Taylor, bradley@railsmachine.com
|
|
4
|
+
#
|
|
5
|
+
# mongrel_cluster Startup script for Mongrel clusters.
|
|
6
|
+
#
|
|
7
|
+
# chkconfig: - 85 15
|
|
8
|
+
# description: mongrel_cluster manages multiple Mongrel processes for use \
|
|
9
|
+
# behind a load balancer.
|
|
10
|
+
#
|
|
11
|
+
|
|
12
|
+
CONF_DIR=/etc/mongrel_cluster
|
|
13
|
+
RETVAL=0
|
|
14
|
+
|
|
15
|
+
case "$1" in
|
|
16
|
+
start)
|
|
17
|
+
mongrel_cluster_ctl start -c $CONF_DIR
|
|
18
|
+
RETVAL=$?
|
|
19
|
+
;;
|
|
20
|
+
stop)
|
|
21
|
+
mongrel_cluster_ctl stop -c $CONF_DIR
|
|
22
|
+
RETVAL=$?
|
|
23
|
+
;;
|
|
24
|
+
restart)
|
|
25
|
+
mongrel_cluster_ctl restart -c $CONF_DIR
|
|
26
|
+
RETVAL=$?
|
|
27
|
+
;;
|
|
28
|
+
*)
|
|
29
|
+
echo "Usage: mongrel_cluster {start|stop|restart}"
|
|
30
|
+
exit 1
|
|
31
|
+
;;
|
|
32
|
+
esac
|
|
33
|
+
|
|
34
|
+
exit $RETVAL
|
metadata
CHANGED
|
@@ -3,8 +3,8 @@ rubygems_version: 0.8.11
|
|
|
3
3
|
specification_version: 1
|
|
4
4
|
name: mongrel_cluster
|
|
5
5
|
version: !ruby/object:Gem::Version
|
|
6
|
-
version: 0.
|
|
7
|
-
date: 2006-
|
|
6
|
+
version: 0.2.0
|
|
7
|
+
date: 2006-06-19 00:00:00 -04:00
|
|
8
8
|
summary: Mongrel plugin that provides commands and Capistrano tasks for managing multiple Mongrel processes.
|
|
9
9
|
require_paths:
|
|
10
10
|
- lib
|
|
@@ -13,7 +13,7 @@ homepage:
|
|
|
13
13
|
rubyforge_project:
|
|
14
14
|
description: Mongrel plugin that provides commands and Capistrano tasks for managing multiple Mongrel processes.
|
|
15
15
|
autorequire:
|
|
16
|
-
default_executable:
|
|
16
|
+
default_executable: mongrel_cluster_ctl
|
|
17
17
|
bindir: bin
|
|
18
18
|
has_rdoc: false
|
|
19
19
|
required_ruby_version: !ruby/object:Gem::Version::Requirement
|
|
@@ -32,19 +32,21 @@ files:
|
|
|
32
32
|
- LICENSE
|
|
33
33
|
- README
|
|
34
34
|
- Rakefile
|
|
35
|
+
- bin/mongrel_cluster_ctl
|
|
35
36
|
- lib/mongrel_cluster
|
|
36
37
|
- lib/mongrel_cluster/init.rb
|
|
37
38
|
- lib/mongrel_cluster/recipes.rb
|
|
38
39
|
- tools/rakehelp.rb
|
|
39
40
|
- resources/defaults.yaml
|
|
41
|
+
- resources/mongrel_cluster
|
|
40
42
|
test_files: []
|
|
41
43
|
|
|
42
44
|
rdoc_options: []
|
|
43
45
|
|
|
44
46
|
extra_rdoc_files:
|
|
45
47
|
- README
|
|
46
|
-
executables:
|
|
47
|
-
|
|
48
|
+
executables:
|
|
49
|
+
- mongrel_cluster_ctl
|
|
48
50
|
extensions: []
|
|
49
51
|
|
|
50
52
|
requirements: []
|
|
@@ -66,5 +68,5 @@ dependencies:
|
|
|
66
68
|
requirements:
|
|
67
69
|
- - ">="
|
|
68
70
|
- !ruby/object:Gem::Version
|
|
69
|
-
version: 0.3.
|
|
71
|
+
version: 0.3.13
|
|
70
72
|
version:
|