mongrel_cluster 0.2.0 → 0.2.1

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 CHANGED
@@ -1,4 +1,4 @@
1
- Copyright (c) 2006 Bradley Taylor, bradley@railsmachine.com
1
+ Copyright (c) 2006 Bradley Taylor, bradley@fluxura.com
2
2
 
3
3
  GNU LESSER GENERAL PUBLIC LICENSE
4
4
  Version 2.1, February 1999
data/LICENSE CHANGED
@@ -1,4 +1,4 @@
1
- Copyright (c) 2006 Bradley Taylor, bradley@railsmachine.com
1
+ Copyright (c) 2006 Bradley Taylor, bradley@fluxura.com
2
2
 
3
3
  GNU LESSER GENERAL PUBLIC LICENSE
4
4
  Version 2.1, February 1999
data/README CHANGED
@@ -14,7 +14,7 @@ mongrel_rails cluster::restart
14
14
  Stop cluster:
15
15
  mongrel_rails cluster::stop
16
16
 
17
- *Capistrano Recipe*
17
+ Capistrano Recipe
18
18
 
19
19
  Add to config/deploy.rb:
20
20
  require 'mongrel_cluster/recipes'
@@ -39,7 +39,7 @@ restart_mongrel_cluster: Restart the Mongrel processes on the app server by star
39
39
  restart: Calls restart_mongrel_cluster to allow Mongrel to be used with the standard Capistrano deploy task.
40
40
  spinner: Calls start_mongrel_cluster to allow Mongrel to be used with the standard Capistrano cold_deploy task.
41
41
 
42
- * Supporting starting clusters on boot. *
42
+ Supporting starting clusters on boot.
43
43
  1. Create mongrel_cluster conf directory (/etc/mongrel_cluster).
44
44
  2. Assign ownership to your capistrano user.
45
45
  3. Copy the init.d script from this gem's resouces directory /etc/init.d.
data/Rakefile CHANGED
@@ -15,7 +15,7 @@ setup_rdoc ['README', 'LICENSE', 'COPYING', 'lib/**/*.rb', 'doc/**/*.rdoc']
15
15
  desc "Does a full compile, test run"
16
16
  task :default => [:test, :package]
17
17
 
18
- version="0.2.0"
18
+ version="0.2.1"
19
19
  name="mongrel_cluster"
20
20
 
21
21
  setup_gem(name, version) do |spec|
@@ -23,7 +23,7 @@ setup_gem(name, version) do |spec|
23
23
  spec.description = spec.summary
24
24
  spec.author="Bradley Taylor"
25
25
  spec.add_dependency('gem_plugin', '>= 0.2.1')
26
- spec.add_dependency('mongrel', '>= 0.3.13')
26
+ spec.add_dependency('mongrel', '>= 0.3.13.4')
27
27
  spec.files += Dir.glob("resources/**/*")
28
28
  spec.has_rdoc = false
29
29
  spec.files += Dir.glob("bin/*")
@@ -1,12 +1,14 @@
1
1
  #!/usr/bin/env ruby
2
- # Copyright (c) 2006 Bradley Taylor, bradley@railsmachine.com
2
+ # Copyright (c) 2006 Bradley Taylor, bradley@fluxura.com
3
3
 
4
4
  require 'optparse'
5
5
 
6
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}"
7
+ Dir.chdir @options[:conf_path] do
8
+ confs = Dir.glob("*.yml")
9
+ confs += Dir.glob("*.conf")
10
+ confs.each do |conf|
11
+ cmd = "mongrel_rails cluster::#{command} -c #{conf}"
10
12
  cmd += " -v" if verbose
11
13
  puts cmd if verbose
12
14
  output = `#{cmd}`
@@ -4,152 +4,130 @@ require 'yaml'
4
4
 
5
5
  module Cluster
6
6
 
7
+ module ExecBase
8
+ include Mongrel::Command::Base
9
+
10
+ def validate
11
+ valid_exists?(@config_file, "Configuration file does not exist. Run mongrel_rails cluster::configure.")
12
+ return @valid
13
+ end
14
+
15
+ def read_options
16
+ @options = {
17
+ "environment" => ENV['RAILS_ENV'] || "development",
18
+ "port" => 3000,
19
+ "pid_file" => "log/mongrel.pid",
20
+ "servers" => 2
21
+ }
22
+ conf = YAML.load_file(@config_file)
23
+ @options.merge! conf if conf
24
+ end
25
+
26
+ def start
27
+ read_options
28
+ port = @options["port"].to_i - 1
29
+ pid = @options["pid_file"].split(".")
30
+ puts "Starting #{@options["servers"]} Mongrel servers..."
31
+ 1.upto(@options["servers"].to_i) do |i|
32
+ argv = [ "mongrel_rails" ]
33
+ argv << "start"
34
+ argv << "-d"
35
+ argv << "-e #{@options["environment"]}" if @options["environment"]
36
+ argv << "-p #{port+i}"
37
+ argv << "-a #{@options["address"]}" if @options["address"]
38
+ argv << "-l #{@options["log_file"]}" if @options["log_file"]
39
+ argv << "-P #{pid[0]}.#{port+i}.#{pid[1]}"
40
+ argv << "-c #{@options["cwd"]}" if @options["cwd"]
41
+ argv << "-t #{@options["timeout"]}" if @options["timeout"]
42
+ argv << "-m #{@options["mime_map"]}" if @options["mime_map"]
43
+ argv << "-r #{@options["docroot"]}" if @options["docroot"]
44
+ argv << "-n #{@options["num_procs"]}" if @options["num_procs"]
45
+ argv << "-B" if @options["debug"]
46
+ argv << "-S #{@options["config_script"]}" if @options["config_script"]
47
+ argv << "--user #{@options["user"]}" if @options["user"]
48
+ argv << "--group #{@options["group"]}" if @options["group"]
49
+ argv << "--prefix #{@options["prefix"]}" if @options["prefix"]
50
+ cmd = argv.join " "
51
+
52
+ puts cmd if @verbose
53
+ output = `#{cmd}`
54
+ unless $?.success?
55
+ puts cmd unless @verbose
56
+ puts output
57
+ end
58
+ end
59
+ end
60
+
61
+ def stop
62
+ read_options
63
+ port = @options["port"].to_i - 1
64
+ pid = @options["pid_file"].split(".")
65
+ puts "Stopping #{@options["servers"]} Mongrel servers..."
66
+ 1.upto(@options["servers"].to_i) do |i|
67
+ argv = [ "mongrel_rails" ]
68
+ argv << "stop"
69
+ argv << "-P #{pid[0]}.#{port+i}.#{pid[1]}"
70
+ argv << "-c #{@options["cwd"]}" if @options["cwd"]
71
+ argv << "-f" if @force
72
+ cmd = argv.join " "
73
+ puts cmd if @verbose
74
+ output = `#{cmd}`
75
+ unless $?.success?
76
+ puts cmd unless @verbose
77
+ puts output
78
+ end
79
+ end
80
+ end
81
+
82
+ end
83
+
7
84
  class Start < GemPlugin::Plugin "/commands"
8
- include Mongrel::Command::Base
85
+ include ExecBase
9
86
 
10
87
  def configure
11
88
  options [
12
- ['-C', '--config PATH', "Path to configuration file", :@config_file, "config/mongrel_cluster.yml"],
89
+ ['-C', '--config PATH', "Path to cluster configuration file", :@config_file, "config/mongrel_cluster.yml"],
13
90
  ['-v', '--verbose', "Print all called commands and output.", :@verbose, false]
14
91
  ]
15
92
  end
16
93
 
17
- def validate
18
- valid_exists?(@config_file, "Configuration file does not exist. Run mongrel_rails cluster::configure.")
19
- return @valid
20
- end
21
-
22
94
  def run
23
- @options = {
24
- "port" => 3000,
25
- "pid_file" => "log/mongrel.pid",
26
- "servers" => 2
27
- }
28
-
29
- @conf_options = YAML.load_file(@config_file)
30
- @options.merge! @conf_options if @conf_options
31
- port = @options["port"].to_i - 1
32
- pid = @options["pid_file"].split(".")
33
- puts "Starting #{@options["servers"]} Mongrel servers..."
34
- 1.upto(@options["servers"].to_i) do |i|
35
- argv = [ "mongrel_rails" ]
36
- argv << "start"
37
- argv << "-d"
38
- argv << "-e #{@options["environment"]}" if @options["environment"]
39
- argv << "-p #{port+i}"
40
- argv << "-a #{@options["address"]}" if @options["address"]
41
- argv << "-l #{@options["log_file"]}" if @options["log_file"]
42
- argv << "-P #{pid[0]}.#{port+i}.#{pid[1]}"
43
- argv << "-c #{@options["cwd"]}" if @options["cwd"]
44
- argv << "-t #{@options["timeout"]}" if @options["timeout"]
45
- argv << "-m #{@options["mime_map"]}" if @options["mime_map"]
46
- argv << "-r #{@options["docroot"]}" if @options["docroot"]
47
- argv << "-n #{@options["num_procs"]}" if @options["num_procs"]
48
- argv << "-B" if @options["debug"]
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"]
52
- cmd = argv.join " "
53
-
54
- puts cmd if @verbose
55
- output = `#{cmd}`
56
- unless $?.success?
57
- puts cmd unless @verbose
58
- puts output
59
- end
60
- end
95
+ start
61
96
  end
62
97
  end
63
98
 
64
99
  class Stop < GemPlugin::Plugin "/commands"
65
- include Mongrel::Command::Base
100
+ include ExecBase
66
101
 
67
102
  def configure
68
103
  options [
69
- ['-C', '--config PATH', "Path to config file", :@config_file, "config/mongrel_cluster.yml"],
104
+ ['-C', '--config PATH', "Path to cluster configuration file", :@config_file, "config/mongrel_cluster.yml"],
70
105
  ['-f', '--force', "Force the shutdown.", :@force, false],
71
106
  ['-v', '--verbose', "Print all called commands and output.", :@verbose, false]
72
107
  ]
73
108
  end
74
-
75
- def validate
76
- valid_exists?(@config_file, "Configuration file does not exist. Run mongrel_rails cluster::configure.")
77
- return @valid
78
- end
79
109
 
80
110
  def run
81
- @options = {
82
- "environment" => ENV['RAILS_ENV'] || "development",
83
- "port" => 3000,
84
- "pid_file" => "log/mongrel.pid",
85
- "servers" => 2
86
- }
87
-
88
- @conf_options = YAML.load_file(@config_file)
89
- @options.merge! @conf_options if @conf_options
90
- port = @options["port"].to_i - 1
91
- pid = @options["pid_file"].split(".")
92
- puts "Stopping #{@options["servers"]} Mongrel servers..."
93
- 1.upto(@options["servers"].to_i) do |i|
94
- argv = [ "mongrel_rails" ]
95
- argv << "stop"
96
- argv << "-P #{pid[0]}.#{port+i}.#{pid[1]}"
97
- argv << "-c #{@options["cwd"]}" if @options["cwd"]
98
- argv << "-f" if @force
99
- cmd = argv.join " "
100
- puts cmd if @verbose
101
- output = `#{cmd}`
102
- unless $?.success?
103
- puts cmd unless @verbose
104
- puts output
105
- end
106
- end
111
+ stop
107
112
  end
108
113
  end
109
114
 
110
115
  class Restart < GemPlugin::Plugin "/commands"
111
- include Mongrel::Command::Base
116
+ include ExecBase
112
117
 
113
118
  def configure
114
119
  options [
115
- ['-C', '--config PATH', "Path to config file", :@config_file, "config/mongrel_cluster.yml"],
116
- ['-s', '--soft', "Do a soft restart rather than a process exit restart", :@soft, false],
120
+ ['-C', '--config PATH', "Path to cluster configuration file", :@config_file, "config/mongrel_cluster.yml"],
121
+ ['-f', '--force', "Force the shutdown.", :@force, false],
117
122
  ['-v', '--verbose', "Print all called commands and output.", :@verbose, false]
118
123
  ]
119
124
  end
120
-
121
- def validate
122
- valid_exists?(@config_file, "Configuration file does not exist. Run mongrel_rails cluster::configure.")
123
- return @valid
124
- end
125
125
 
126
126
  def run
127
- @options = {
128
- "port" => 3000,
129
- "pid_file" => "log/mongrel.pid",
130
- "servers" => 2
131
- }
132
-
133
- @conf_options = YAML.load_file(@config_file)
134
- @options.merge! @conf_options if @conf_options
135
- port = @options["port"].to_i - 1
136
- pid = @options["pid_file"].split(".")
137
- puts "Restarting #{@options["servers"]} Mongrel servers..."
138
- 1.upto(@options["servers"].to_i) do |i|
139
- argv = [ "mongrel_rails" ]
140
- argv << "restart"
141
- argv << "-P #{pid[0]}.#{port+i}.#{pid[1]}"
142
- argv << "-c #{@options["cwd"]}" if @options["cwd"]
143
- argv << "-s" if @soft
144
- cmd = argv.join " "
145
- puts cmd if @verbose
146
- output = `#{cmd}`
147
- unless $?.success?
148
- puts cmd unless @verbose
149
- puts output
150
- end
151
- end
152
- end
127
+ stop
128
+ start
129
+ end
130
+
153
131
  end
154
132
 
155
133
  class Configure < GemPlugin::Plugin "/commands"
@@ -170,9 +148,10 @@ module Cluster
170
148
  ['-B', '--debug', "Enable debugging mode", :@debug, nil],
171
149
  ['-S', '--script PATH', "Load the given file as an extra config script.", :@config_script, nil],
172
150
  ['-N', '--num-servers INT', "Number of Mongrel servers", :@servers, 2],
173
- ['-C', '--config PATH', "Path to config file", :@config_file, "config/mongrel_cluster.yml"],
151
+ ['-C', '--config PATH', "Path to cluster configuration file", :@config_file, "config/mongrel_cluster.yml"],
174
152
  ['', '--user USER', "User to run as", :@user, nil],
175
- ['', '--group GROUP', "Group to run as", :@group, nil]
153
+ ['', '--group GROUP', "Group to run as", :@group, nil],
154
+ ['', '--prefix PREFIX', "Rails prefix to use", :@prefix, nil]
176
155
  ]
177
156
  end
178
157
 
@@ -204,6 +183,7 @@ module Cluster
204
183
  @options["cwd"] = @cwd if @cwd
205
184
  @options["user"] = @user if @user
206
185
  @options["group"] = @group if @group
186
+ @options["prefix"] = @prefix if @prefix
207
187
 
208
188
  puts "Writing configuration file to #{@config_file}."
209
189
  File.open(@config_file,"w") {|f| f.write(@options.to_yaml)}
@@ -6,6 +6,7 @@ Capistrano.configuration(:must_exist).load do
6
6
  set :mongrel_conf, nil
7
7
  set :mongrel_user, nil
8
8
  set :mongrel_group, nil
9
+ set :mongrel_prefix, nil
9
10
 
10
11
  desc <<-DESC
11
12
  Configure Mongrel processes on the app server. This uses the :use_sudo
@@ -25,6 +26,7 @@ Capistrano.configuration(:must_exist).load do
25
26
  argv << "-C #{mongrel_conf}"
26
27
  argv << "--user #{mongrel_user}" if mongrel_user
27
28
  argv << "--group #{mongrel_group}" if mongrel_group
29
+ argv << "--prefix #{mongrel_prefix}" if mongrel_prefix
28
30
  cmd = argv.join " "
29
31
  send(run_method, cmd)
30
32
  end
@@ -43,8 +45,8 @@ Capistrano.configuration(:must_exist).load do
43
45
  variable to determine whether to use sudo or not. By default, :use_sudo is set to true.
44
46
  DESC
45
47
  task :restart_mongrel_cluster , :roles => :app do
46
- stop_mongrel_cluster
47
- start_mongrel_cluster
48
+ set_mongrel_conf
49
+ send(run_method, "mongrel_rails cluster::restart -C #{mongrel_conf}")
48
50
  end
49
51
 
50
52
  desc <<-DESC
@@ -72,7 +74,7 @@ Capistrano.configuration(:must_exist).load do
72
74
  end
73
75
 
74
76
  def set_mongrel_conf
75
- set :mongrel_conf, "/etc/mongrel_cluster/#{application}.conf" unless mongrel_conf
77
+ set :mongrel_conf, "/etc/mongrel_cluster/#{application}.yml" unless mongrel_conf
76
78
  end
77
79
 
78
80
  end
@@ -12,6 +12,13 @@
12
12
  CONF_DIR=/etc/mongrel_cluster
13
13
  RETVAL=0
14
14
 
15
+
16
+ # Gracefully exit if the controller is missing.
17
+ which mongrel_cluster_ctl >/dev/null || exit 0
18
+
19
+ # Go no further if config directory is missing.
20
+ [ -d "$CONF_DIR" ] || exit 0
21
+
15
22
  case "$1" in
16
23
  start)
17
24
  mongrel_cluster_ctl start -c $CONF_DIR
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.2.0
7
- date: 2006-06-19 00:00:00 -04:00
6
+ version: 0.2.1
7
+ date: 2006-09-11 00:00:00 -07:00
8
8
  summary: Mongrel plugin that provides commands and Capistrano tasks for managing multiple Mongrel processes.
9
9
  require_paths:
10
10
  - lib
@@ -34,11 +34,11 @@ files:
34
34
  - Rakefile
35
35
  - bin/mongrel_cluster_ctl
36
36
  - lib/mongrel_cluster
37
- - lib/mongrel_cluster/init.rb
38
37
  - lib/mongrel_cluster/recipes.rb
38
+ - lib/mongrel_cluster/init.rb
39
39
  - tools/rakehelp.rb
40
- - resources/defaults.yaml
41
40
  - resources/mongrel_cluster
41
+ - resources/defaults.yaml
42
42
  test_files: []
43
43
 
44
44
  rdoc_options: []
@@ -68,5 +68,5 @@ dependencies:
68
68
  requirements:
69
69
  - - ">="
70
70
  - !ruby/object:Gem::Version
71
- version: 0.3.13
71
+ version: 0.3.13.4
72
72
  version: