capitate 0.2.3 → 0.2.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (54) hide show
  1. data/History.txt +14 -0
  2. data/Manifest.txt +10 -2
  3. data/docs/recipes/imagemagick-centos.txt +6 -0
  4. data/docs/recipes/index.txt +9 -6
  5. data/docs/recipes/memcached-centos.txt +7 -0
  6. data/docs/recipes/memcached-monit.txt +30 -0
  7. data/docs/recipes/memcached.txt +1 -27
  8. data/docs/recipes/{mongrel_cluster-centos.txt → mongrel-cluster-centos.txt} +12 -8
  9. data/docs/recipes/{mongrel_cluster.txt → mongrel-cluster-monit.txt} +12 -16
  10. data/docs/recipes/mongrel-cluster.txt +9 -0
  11. data/docs/recipes/mongrel.txt +9 -0
  12. data/docs/recipes/monit-centos.txt +2 -0
  13. data/docs/recipes/mysql-monit.txt +28 -0
  14. data/docs/recipes/mysql.txt +3 -19
  15. data/docs/recipes/nginx-centos.txt +9 -0
  16. data/docs/recipes/nginx-mongrel.txt +33 -0
  17. data/docs/recipes/nginx-monit.txt +26 -0
  18. data/docs/recipes/nginx.txt +2 -44
  19. data/docs/recipes/ruby-centos.txt +9 -0
  20. data/docs/recipes/sphinx-centos.txt +8 -0
  21. data/docs/recipes/sphinx-monit.txt +22 -0
  22. data/docs/recipes/sphinx.txt +1 -11
  23. data/lib/capitate/cap_ext/connections.rb +15 -13
  24. data/lib/capitate/cap_ext/roles.rb +26 -0
  25. data/lib/capitate/plugins/base.rb +1 -0
  26. data/lib/capitate/plugins/prompt.rb +49 -6
  27. data/lib/capitate/plugins/script.rb +17 -13
  28. data/lib/capitate/recipes.rb +0 -3
  29. data/lib/capitate/version.rb +1 -1
  30. data/lib/capitate.rb +3 -0
  31. data/lib/deployment/deploy.rb +4 -7
  32. data/lib/deployment/install-centos-rubyweb.rb +3 -3
  33. data/lib/recipes/centos/centos.rb +17 -9
  34. data/lib/recipes/centos/imagemagick.rb +6 -0
  35. data/lib/recipes/centos/memcached.rb +6 -0
  36. data/lib/recipes/centos/mongrel_cluster.rb +42 -28
  37. data/lib/recipes/centos/monit.rb +2 -1
  38. data/lib/recipes/centos/mysql.rb +1 -1
  39. data/lib/recipes/centos/nginx.rb +8 -0
  40. data/lib/recipes/centos/ruby.rb +10 -2
  41. data/lib/recipes/centos/sphinx.rb +8 -1
  42. data/lib/recipes/memcached.rb +20 -22
  43. data/lib/recipes/mongrel_cluster.rb +60 -50
  44. data/lib/recipes/mysql.rb +21 -17
  45. data/lib/recipes/nginx.rb +47 -39
  46. data/lib/recipes/rails.rb +10 -0
  47. data/lib/recipes/sphinx.rb +15 -11
  48. data/lib/templates/mongrel/mongrel_cluster.initd.erb +6 -6
  49. data/lib/templates/mongrel/mongrel_cluster.monitrc.erb +2 -2
  50. data/lib/templates/mongrel/mongrel_cluster.yml.erb +1 -1
  51. data/lib/templates/nginx/nginx_vhost.conf.erb +8 -4
  52. data/lib/templates/rails/database.yml.erb +1 -2
  53. data/website/index.html +1 -1
  54. metadata +21 -6
@@ -1,3 +1,4 @@
1
+ require 'md5'
1
2
 
2
3
  module Capitate::Plugins::Prompt
3
4
 
@@ -5,21 +6,63 @@ module Capitate::Plugins::Prompt
5
6
  Capistrano::CLI.ui.ask(label, &block)
6
7
  end
7
8
 
8
- def password(label, verify = false, lazy = true)
9
+ # Prompt for password.
10
+ #
11
+ # ==== Options
12
+ # +label+:: Label
13
+ # +options+:: Options
14
+ # - +verify+:: If true, prompt twice and verify
15
+ # - +lazy+:: If true, returns a block. _Defaults to true_
16
+ # - +check_hash+:: If present, checks that md5 is same as password md5
17
+ #
18
+ def password(label, options = {})
19
+
20
+ verify = options[:verify]
21
+ lazy = options[:lazy].nil? ? true : options[:lazy]
22
+ check_hash = options[:check_hash]
23
+
9
24
  # Lazy
10
25
  password_prompt = Proc.new {
11
- password = Capistrano::CLI.password_prompt(label)
26
+
27
+ max_attempts = 2
28
+ attempts = 0
29
+ password = nil
30
+ success = true
31
+
32
+ loop {
33
+ password = Capistrano::CLI.password_prompt(label)
34
+ attempts += 1
12
35
 
13
- if verify
14
- password_verify = Capistrano::CLI.password_prompt("[VERIFY] #{label}")
15
- raise "Passwords do not match" if password != password_verify
16
- end
36
+ if verify
37
+ password_verify = Capistrano::CLI.password_prompt("[VERIFY] #{label}")
38
+ if password != password_verify
39
+ logger.important "Passwords do not match"
40
+ success = false
41
+ end
42
+ end
43
+
44
+ if check_hash
45
+ if MD5.md5(password).hexdigest != check_hash
46
+ logger.important "Invalid password, try again."
47
+ success = false
48
+ end
49
+ end
50
+
51
+ break if success
52
+ break if attempts >= max_attempts
53
+ }
54
+
55
+ raise "Invalid password, too many tries" unless success
17
56
 
18
57
  password
19
58
  }
20
59
 
21
60
  return password_prompt if lazy
22
61
  password_prompt.call
62
+ end
63
+
64
+ def check_password_hash(password, hash)
65
+ MD5.md5()
23
66
  end
24
67
 
25
68
  end
@@ -51,11 +51,8 @@ module Capitate::Plugins::Script
51
51
  build_dest = options[:build_dest]
52
52
  build_dest ||= "/tmp/#{name}"
53
53
  url = options[:url]
54
- dependencies = options[:dependencies]
55
54
 
56
- package.install(dependencies) if dependencies
57
-
58
- unpack(url, build_dest, options[:clean], options[:unpack_dir]) do |dir|
55
+ unpack(url, build_dest, options) do |dir|
59
56
  yield(dir) if block_given?
60
57
  end
61
58
  end
@@ -85,7 +82,10 @@ module Capitate::Plugins::Script
85
82
  end
86
83
 
87
84
  # If want verbose, -v
88
- run_via "sh -v #{dest} && rm -rf #{File.dirname(dest)}"
85
+ run_all <<-CMDS
86
+ sh -v #{dest}
87
+ rm -rf #{File.dirname(dest)}
88
+ CMDS
89
89
  end
90
90
 
91
91
  # Download and unpack URL.
@@ -94,15 +94,16 @@ module Capitate::Plugins::Script
94
94
  # ==== Options
95
95
  # +url+:: URL to download
96
96
  # +dest+:: Destination directory
97
- # +clean+:: If true will remove the unpacked directory
98
- # +unpack_dir+:: Directory that is unpacked from tgz (if not matching the file name)
97
+ # +options+::
98
+ # - +clean+:: If true will remove the unpacked directory. _Defaults to true_
99
+ # - +unpack_dir+:: Directory that is unpacked from tgz (if not matching the file name)
99
100
  #
100
101
  # ==== Examples
101
102
  # script.unpack("http://rubyforge.org/frs/download.php/29548/rubygems-1.0.1.tgz", "/tmp/rubygems") do
102
103
  # sudo "ruby setup.rb"
103
104
  # end
104
105
  #
105
- def unpack(url, dest, clean = true, unpack_dir = nil, &block)
106
+ def unpack(url, dest, options, &block)
106
107
  file = url.split("/").last
107
108
 
108
109
  # TODO: Support other types
@@ -110,12 +111,16 @@ module Capitate::Plugins::Script
110
111
  raise "Can't unpack this file: #{file}; only support tar.gz and tgz formats"
111
112
  end
112
113
 
114
+ options[:clean] = true if options[:clean].nil?
115
+ unpack_dir = options[:unpack_dir]
116
+ clean = options[:clean]
117
+
113
118
  unpack_dir ||= file.gsub(/\.tar\.gz|\.tgz/, "")
114
119
 
115
120
  http_get_method = fetch(:http_get_method, "wget -nv")
116
-
121
+
117
122
  run_all <<-CMDS
118
- mkdir -p #{dest} && cd #{dest} && #{http_get_method} #{url}
123
+ sh -c "mkdir -p #{dest} && cd #{dest} && #{http_get_method} #{url}"
119
124
  sh -c "cd #{dest} && tar zxf #{file}"
120
125
  CMDS
121
126
 
@@ -133,10 +138,9 @@ module Capitate::Plugins::Script
133
138
  # +cmds+:: Commands (separated by newlines)
134
139
  # +options+:: See invoke_command options
135
140
  #
136
- def run_all(cmds, options = {}, &block)
141
+ def run_all(cmds, options = {}, &block)
137
142
  cmds.split("\n").each do |cmd|
138
- cmd = cmd.gsub(/^\s+/, "")
139
- #sh_cmd = %{sh -c "#{cmd.gsub("\"", "\"\"")}"}
143
+ cmd = cmd.gsub(/^\s+/, "")
140
144
  run_via(cmd, options, &block)
141
145
  end
142
146
  end
@@ -3,6 +3,3 @@ recipes = Dir[File.dirname(__FILE__) + "/../recipes/**/*.rb"].collect { |recipe|
3
3
  recipes.each do |recipe|
4
4
  Capistrano::Configuration.instance.load recipe
5
5
  end
6
-
7
- # Reset the password var
8
- Capistrano::Configuration.instance.load(:string => "reset_password")
@@ -2,7 +2,7 @@ module Capitate #:nodoc:
2
2
  module VERSION #:nodoc:
3
3
  MAJOR = 0
4
4
  MINOR = 2
5
- TINY = 3
5
+ TINY = 5
6
6
 
7
7
  STRING = [MAJOR, MINOR, TINY].join('.')
8
8
  end
data/lib/capitate.rb CHANGED
@@ -21,14 +21,17 @@ require 'capitate/plugins/templates'
21
21
  require 'capitate/plugins/upload'
22
22
  require 'capitate/plugins/yum'
23
23
 
24
+ # Extensions + Patches
24
25
  require "capitate/cap_ext/connections"
25
26
  require "capitate/cap_ext/extension_proxy"
26
27
  require "capitate/cap_ext/variables"
27
28
  require "capitate/cap_ext/run_via"
29
+ require "capitate/cap_ext/roles"
28
30
 
29
31
  class Capistrano::Configuration
30
32
  include Capitate::CapExt::Variables
31
33
  include Capitate::CapExt::RunVia
34
+ include Capitate::CapExt::Roles
32
35
  end
33
36
 
34
37
  require 'capitate/task_node'
@@ -28,15 +28,12 @@ role :db, "192.168.1.111", :primary => true
28
28
  # Callbacks
29
29
  before "deploy:setup", "centos:add_user"
30
30
 
31
- after "deploy:setup", "mysql:setup", "rails:setup", "mongrel_cluster:centos:setup",
32
- "nginx:setup_mongrel", "sphinx:centos:setup"
31
+ after "deploy:setup", "mysql:setup", "rails:setup", "mongrel:cluster:centos:setup",
32
+ "nginx:mongrel:setup", "sphinx:centos:setup", "sphinx:setup_monit", "mongrel:cluster:monit:setup"
33
33
 
34
- after "sphinx:centos:setup", "sphinx:setup_monit"
35
- after "mongrel_cluster:centos:setup", "mongrel_cluster:setup_monit"
34
+ after "nginx:mongrel:setup", "nginx:centos:restart"
36
35
 
37
- after "nginx:setup_mongrels", "nginx:centos:restart"
38
-
39
- after "deploy:update_code", "rails:update_code", "sphinx:update_code"
36
+ after "deploy:update_code", "rails:update_code", "sphinx:update_conf"
40
37
 
41
38
  # Auto cleanup after deploy
42
39
  after "deploy", "deploy:cleanup"
@@ -53,12 +53,12 @@ task :install do
53
53
  #
54
54
  # Install monit hooks
55
55
  #
56
- nginx.install_monit
57
- mysql.install_monit
56
+ nginx.monit.install
57
+ mysql.monit.install
58
58
 
59
59
  # Gem installs
60
60
  gems.install([ "rake", "mysql -- --with-mysql-include=/usr/include/mysql --with-mysql-lib=/usr/lib/mysql --with-mysql-config",
61
- "raspell", "rmagick", "mongrel", "mongrel_cluster","json" ])
61
+ "raspell", "rmagick", "mongrel", "mongrel_cluster","json", "mime-types" ])
62
62
 
63
63
  # Cleanup
64
64
  yum.clean
@@ -26,18 +26,26 @@ namespace :centos do
26
26
  adduser_options << "-d #{home}" unless home.blank?
27
27
  adduser_options << "-G #{groups}" unless groups.blank?
28
28
 
29
- run "id #{user_add} || /usr/sbin/adduser #{adduser_options.join(" ")} #{user_add}"
30
-
31
- run "chmod a+rx #{home}" if home_readable
29
+ user_existed = false
30
+ run "id #{user_add} || /usr/sbin/adduser #{adduser_options.join(" ")} #{user_add}" do |channel, stream, data|
31
+ logger.info data
32
+ user_existed = data =~ /uid/
33
+ end
34
+
35
+ logger.info "User already existed, aborting..." if user_existed
36
+
37
+ unless user_existed
38
+ run "chmod a+rx #{home}" if home_readable
32
39
 
33
- new_password = prompt.password("Password to set for #{user_add}: ", true, false)
40
+ new_password = prompt.password("Password to set for #{user_add}: ", :verify => true, :lazy => false)
34
41
 
35
- run "passwd #{user_add}" do |channel, stream, data|
36
- logger.info data
42
+ run "passwd #{user_add}" do |channel, stream, data|
43
+ logger.info data
37
44
 
38
- if data =~ /password:/i
39
- channel.send_data "#{new_password}\n"
40
- channel.send_data "#{new_password}\n"
45
+ if data =~ /password:/i
46
+ channel.send_data "#{new_password}\n"
47
+ channel.send_data "#{new_password}\n"
48
+ end
41
49
  end
42
50
  end
43
51
 
@@ -4,6 +4,12 @@ namespace :imagemagick do
4
4
  desc <<-DESC
5
5
  Install imagemagick.\n
6
6
  *imagemagick_build_options*: Imagemagick build options.
7
+ <pre>
8
+ set :imagemagick_build_options, {
9
+ :url => "ftp://ftp.imagemagick.org/pub/ImageMagick/ImageMagick.tar.gz",
10
+ :unpack_dir => "ImageMagick-*"
11
+ }
12
+ </pre>
7
13
  DESC
8
14
  task :install do
9
15
 
@@ -6,6 +6,12 @@ namespace :memcached do
6
6
  Install memcached.
7
7
 
8
8
  *memcached_build_options*: Memcached build options.\n
9
+ <pre>
10
+ set :memcached_build_options, {
11
+ :url => "http://www.danga.com/memcached/dist/memcached-1.2.4.tar.gz",
12
+ :configure_options => "--prefix=/usr/local"
13
+ }
14
+ </pre>\n
9
15
  *memcached_memory*: Memcached memory (in MB).\n
10
16
  @set :memcached_memory, 64@\n
11
17
  *memcached_pid_path*: Path to memcached pid file. Defaults to /var/run/memcached.pid\n
@@ -1,40 +1,54 @@
1
- namespace :mongrel_cluster do
1
+ namespace :mongrel do
2
+
3
+ namespace :cluster do
2
4
 
3
- namespace :centos do
5
+ namespace :centos do
4
6
 
5
- desc <<-DESC
6
- Create mongrel cluster.
7
+ desc <<-DESC
8
+ Create mongrel cluster.
7
9
 
8
- *mongrel_size*: Number of mongrels.\n
9
- @set :mongrel_size, 3@\n
10
- *mongrel_port*: Starting port for mongrels. If there are 3 mongrels with port 9000,
11
- then instances will be at 9000, 9001, and 9002\n
12
- @set :mongrel_port, 9000@\n
13
- *mongrel_config_dir*: Directory for mongrel config. _Defaults to "[shared_path]/config/mongrel"_
14
- *mongrel_pid_dir*: Directory for mongrel pids. _Defaults to "[shared_path]/pids"
15
- *mongrel_config_script*: Config script to load with mongrel. _Defaults to nil_\n
16
- @set :mongrel_config_script, "config/mongrel_handler.rb"@\n
17
- DESC
18
- task :setup do
10
+ *mongrel_size*: Number of mongrels.\n
11
+ @set :mongrel_size, 3@\n
12
+ *mongrel_port*: Starting port for mongrels. If there are 3 mongrels with port 9000,
13
+ then instances will be at 9000, 9001, and 9002\n
14
+ @set :mongrel_port, 9000@\n
15
+ *mongrel_config_dir*: Directory for mongrel config. _Defaults to "[shared_path]/config/mongrel"_
16
+ *mongrel_pid_dir*: Directory for mongrel pids. _Defaults to "[shared_path]/pids"
17
+ *mongrel_config_script*: Config script to load with mongrel. _Defaults to nil_\n
18
+ @set :mongrel_config_script, "config/mongrel_handler.rb"@\n
19
+ *mongrel_cluster_command*: Mongrel cluster command. _Defaults to mongrel_cluster_ctl_
20
+ *mongrel_initscript_name*: Mongrel initscript name. _Defaults to mongrel_cluster_\#{application}_
21
+ *mongrel_config_options*: Config options appended to cluster yml. _Defaults to <tt>{}</tt>_
22
+ DESC
23
+ task :setup do
19
24
 
20
- # Settings
21
- fetch(:mongrel_size)
22
- fetch(:mongrel_port)
23
- fetch_or_default(:mongrel_config_dir, "#{shared_path}/config/mongrel")
24
- fetch_or_default(:mongrel_pid_dir, "#{shared_path}/pids")
25
- fetch_or_default(:mongrel_config_script, nil)
25
+ # Settings
26
+ fetch(:mongrel_size)
27
+ fetch(:mongrel_port)
28
+ fetch_or_default(:mongrel_config_dir, "#{shared_path}/config/mongrel")
29
+ fetch_or_default(:mongrel_pid_dir, "#{shared_path}/pids")
30
+ fetch_or_default(:mongrel_config_script, nil)
31
+
32
+ fetch_or_default(:mongrel_cluster_command, "mongrel_cluster_ctl")
33
+ fetch_or_default(:mongrel_initscript_name, "mongrel_cluster_#{application}")
34
+ fetch_or_default(:mongrel_config_options, {})
35
+
36
+ unless mongrel_config_script.blank?
37
+ mongrel_config_options["config_script"] = mongrel_config_script
38
+ end
26
39
 
27
- run "mkdir -p #{mongrel_config_dir}"
40
+ run "mkdir -p #{mongrel_config_dir}"
28
41
 
29
- put template.load("mongrel/mongrel_cluster.initd.erb"), "/tmp/mongrel_cluster_#{application}.initd"
30
- put template.load("mongrel/mongrel_cluster.yml.erb"), "#{mongrel_config_dir}/mongrel_cluster.yml"
42
+ put template.load("mongrel/mongrel_cluster.initd.erb"), "/tmp/#{mongrel_initscript_name}.initd"
43
+ put template.load("mongrel/mongrel_cluster.yml.erb"), "#{mongrel_config_dir}/mongrel_cluster.yml"
31
44
 
32
- # Setup the mongrel_cluster init script
33
- sudo "install -o root /tmp/mongrel_cluster_#{application}.initd /etc/init.d/mongrel_cluster_#{application}"
45
+ # Setup the mongrel_cluster init script
46
+ sudo "install -o root /tmp/#{mongrel_initscript_name}.initd /etc/init.d/#{mongrel_initscript_name}"
34
47
 
35
- sudo "/sbin/chkconfig --level 345 mongrel_cluster_#{application} on"
36
- end
48
+ sudo "/sbin/chkconfig --level 345 #{mongrel_initscript_name} on"
49
+ end
37
50
 
51
+ end
38
52
 
39
53
  end
40
54
 
@@ -6,6 +6,7 @@ namespace :monit do
6
6
  Install monit.
7
7
 
8
8
  *monit_build_options*: Monit build options.\n
9
+ @set :monit_build_options, { :url => "http://www.tildeslash.com/monit/dist/monit-4.10.1.tar.gz" }@\n
9
10
  *monit_port*: Monit port. _Defaults to 2812_\n
10
11
  @set :monit_port, 2812@\n
11
12
  *monit_password*: Monit password. _Defaults to password prompt_\n
@@ -19,7 +20,7 @@ namespace :monit do
19
20
 
20
21
  # Settings
21
22
  fetch_or_default(:monit_port, 2812)
22
- fetch_or_default(:monit_password, prompt.password('Monit admin password (to set): ', true))
23
+ fetch_or_default(:monit_password, prompt.password('Monit admin password (to set): ', :verify => true))
23
24
  fetch_or_default(:monit_conf_dir, "/etc/monit")
24
25
  fetch_or_default(:monit_pid_path, "/var/run/monit.pid")
25
26
  fetch(:monit_build_options)
@@ -11,7 +11,7 @@ namespace :mysql do
11
11
  task :install do
12
12
 
13
13
  # Settings
14
- fetch_or_default(:mysql_admin_password_set, prompt.password('Mysql admin password (to set): ', true))
14
+ fetch_or_default(:mysql_admin_password_set, prompt.password('Mysql admin password (to set): ', :verify => true))
15
15
 
16
16
  # Install through package manager
17
17
  yum.install([ "mysql", "mysql-devel", "mysql-server" ])
@@ -6,6 +6,14 @@ namespace :nginx do
6
6
  Install nginx, conf, initscript, nginx user and service.
7
7
 
8
8
  *nginx_build_options*: Nginx build options.\n
9
+ <pre>
10
+ set :nginx_build_options, {
11
+ :url => "http://sysoev.ru/nginx/nginx-0.5.35.tar.gz",
12
+ :configure_options => "--sbin-path=\#{nginx_bin_path} --conf-path=\#{nginx_conf_path}
13
+ --pid-path=\#{nginx_pid_path} --error-log-path=/var/log/nginx_master_error.log --lock-path=/var/lock/nginx
14
+ --prefix=\#{nginx_prefix_path} --with-md5=auto/lib/md5 --with-sha1=auto/lib/sha1 --with-http_ssl_module"
15
+ }
16
+ </pre>\n
9
17
  *nginx_bin_path*: Nginx sbin path. _Defaults to /sbin/nginx_\n
10
18
  @set :nginx_bin_path, "/sbin/nginx"@\n
11
19
  *nginx_conf_path*: Path to nginx conf. _Defaults to /etc/nginx/nginx.conf_\n
@@ -7,6 +7,14 @@ namespace :ruby do
7
7
 
8
8
  *ruby_build_options*: Ruby build options.\n
9
9
  *rubygems_build_options*: Rubygems build options.\n
10
+ <pre>
11
+ set :ruby_build_options, {
12
+ :url => "http://capitate.s3.amazonaws.com/ruby-1.8.6-p110.tar.gz",
13
+ :build_dest => "/usr/src",
14
+ :configure_options => "--prefix=/usr",
15
+ :clean => false
16
+ }
17
+ </pre>
10
18
  DESC
11
19
  task :install do
12
20
 
@@ -15,14 +23,14 @@ namespace :ruby do
15
23
  fetch(:rubygems_build_options)
16
24
 
17
25
  # Install dependencies
18
- yum.install([ "zlib", "zlib-devel" ])
26
+ yum.install([ "zlib", "zlib-devel", "readline-devel" ])
19
27
 
20
28
  # Install ruby 1.8.6
21
29
  script.make_install("ruby", ruby_build_options)
22
30
 
23
31
  # Install rubygems
24
32
  script.install("rubygems", rubygems_build_options) do |dir|
25
- run_via "echo 'Running setup...' && cd #{dir} && ruby setup.rb > install.log"
33
+ run_via "cd #{dir} && ruby setup.rb > install.log", { :shell => true }
26
34
  end
27
35
 
28
36
  end
@@ -4,7 +4,14 @@ namespace :sphinx do
4
4
 
5
5
  desc <<-DESC
6
6
  Install sphinx.\n
7
- *sphinx_build_options*: Sphinx build options.\n
7
+ *sphinx_build_options*: Sphinx build options.\n
8
+ <pre>
9
+ set :sphinx_build_options, {
10
+ :url => "http://www.sphinxsearch.com/downloads/sphinx-0.9.7.tar.gz",
11
+ :configure_options => "--with-mysql-includes=/usr/include/mysql --with-mysql-libs=/usr/lib/mysql
12
+ --prefix=\#{sphinx_prefix}"
13
+ }
14
+ </pre>\n
8
15
  *sphinx_prefix*: Sphinx install prefix. _Defaults to "/usr/local/sphinx"_\n
9
16
  DESC
10
17
  task :install do
@@ -1,30 +1,28 @@
1
1
  namespace :memcached do
2
2
 
3
- desc <<-DESC
4
- Generate and install memcached monitrc.
3
+ namespace :monit do
5
4
 
6
- *memcached_pid_path*: Path to memcached pid file. _Defaults to /var/run/memcached.pid_
7
-
8
- @set :memcached_pid_path, "/var/run/memcached.pid"@
9
-
10
- *memcached_port*: Memcached port. _Defaults to 11211_
11
-
12
- @set :memcached_port, 11211@
13
-
14
- *monit_conf_dir*: Destination for monitrc. _Defaults to "/etc/monit"_
15
-
16
- @set :monit_conf_dir, "/etc/monit"@
17
-
18
- DESC
19
- task :install_monit do
5
+ desc <<-DESC
6
+ Generate and install memcached monitrc.
7
+
8
+ *memcached_pid_path*: Path to memcached pid file. _Defaults to /var/run/memcached.pid_\n
9
+ @set :memcached_pid_path, "/var/run/memcached.pid"@\n
10
+ *memcached_port*: Memcached port. _Defaults to 11211_\n
11
+ @set :memcached_port, 11211@\n
12
+ *monit_conf_dir*: Destination for monitrc. _Defaults to "/etc/monit"_\n
13
+ @set :monit_conf_dir, "/etc/monit"@\n
14
+ DESC
15
+ task :install do
16
+
17
+ # Settings
18
+ fetch_or_default(:memcached_pid_path, "/var/run/memcached.pid")
19
+ fetch_or_default(:memcached_port, 11211)
20
+ fetch_or_default(:monit_conf_dir, "/etc/monit")
20
21
 
21
- # Settings
22
- fetch_or_default(:memcached_pid_path, "/var/run/memcached.pid")
23
- fetch_or_default(:memcached_port, 11211)
24
- fetch_or_default(:monit_conf_dir, "/etc/monit")
22
+ put template.load("memcached/memcached.monitrc.erb"), "/tmp/memcached.monitrc"
23
+ run_via "install -o root /tmp/memcached.monitrc #{monit_conf_dir}/memcached.monitrc"
24
+ end
25
25
 
26
- put template.load("memcached/memcached.monitrc.erb"), "/tmp/memcached.monitrc"
27
- run_via "install -o root /tmp/memcached.monitrc #{monit_conf_dir}/memcached.monitrc"
28
26
  end
29
27
 
30
28
  end
@@ -1,63 +1,73 @@
1
1
  # Create init script
2
- namespace :mongrel_cluster do
2
+ namespace :mongrel do
3
3
 
4
- desc <<-DESC
5
- Create monit configuration for mongrel cluster.
4
+ namespace :cluster do
5
+
6
+ namespace :monit do
7
+
8
+ desc <<-DESC
9
+ Create monit configuration for mongrel cluster.
6
10
 
7
- *mongrel_size*: Number of mongrels.\n
8
- @set :mongrel_size, 3@\n
9
- *mongrel_port*: Starting port for mongrels. If there are 3 mongrels with port 9000, then instances
10
- will be at 9000, 9001, and 9002\n
11
- @set :mongrel_port, 9000@\n
12
- *mongrel_config_script*: Config script to load with mongrel. _Defaults to nil_\n
13
- @set :mongrel_config_script, "config/mongrel_handler.rb"@\n
14
- *monit_conf_dir*: Destination for monitrc. _Defaults to "/etc/monit"_\n
15
- @set :monit_conf_dir, "/etc/monit"@\n
16
- DESC
17
- task :setup_monit do
18
-
19
- # See http://www.igvita.com/2006/11/07/monit-makes-mongrel-play-nice/
20
-
21
- # TODO: For depends on memcached setting
22
- # See http://blog.labratz.net/articles/2007/5/1/monit-for-your-uptime
23
-
24
- # Settings
25
- fetch(:mongrel_size)
26
- fetch(:mongrel_port)
27
- fetch_or_default(:mongrel_config_script, nil)
28
- fetch_or_default(:monit_conf_dir, "/etc/monit")
29
-
30
- processes = []
31
- ports = (0...mongrel_size).collect { |i| mongrel_port + i }
32
- ports.each do |port|
11
+ *mongrel_application*: Name of application (monit group). _Defaults to <tt>"mongrel_cluster_\#{fetch(:application)}"</tt>_
12
+ *mongrel_size*: Number of mongrels.\n
13
+ @set :mongrel_size, 3@\n
14
+ *mongrel_port*: Starting port for mongrels. If there are 3 mongrels with port 9000, then instances
15
+ will be at 9000, 9001, and 9002\n
16
+ @set :mongrel_port, 9000@\n
17
+ *mongrel_config_script*: Config script to load with mongrel. _Defaults to nil_\n
18
+ @set :mongrel_config_script, "config/mongrel_handler.rb"@\n
19
+ *monit_conf_dir*: Destination for monitrc. _Defaults to "/etc/monit"_\n
20
+ @set :monit_conf_dir, "/etc/monit"@\n
21
+ DESC
22
+ task :setup do
23
+
24
+ # See http://www.igvita.com/2006/11/07/monit-makes-mongrel-play-nice/
25
+
26
+ # TODO: For depends on memcached setting
27
+ # See http://blog.labratz.net/articles/2007/5/1/monit-for-your-uptime
28
+
29
+ # Settings
30
+ fetch(:mongrel_size)
31
+ fetch(:mongrel_port)
32
+ fetch_or_default(:mongrel_application, Proc.new { "mongrel_cluster_#{fetch(:application)}" })
33
+ fetch_or_default(:mongrel_config_script, nil)
34
+ fetch_or_default(:monit_conf_dir, "/etc/monit")
35
+
36
+ processes = []
37
+ ports = (0...mongrel_size).collect { |i| mongrel_port + i }
38
+ ports.each do |port|
33
39
 
34
- pid_path = "#{shared_path}/pids/mongrel.#{port}.pid"
40
+ pid_path = "#{shared_path}/pids/mongrel.#{port}.pid"
35
41
 
36
- default_options = [
37
- [ "-d" ],
38
- [ "-e", "production" ],
39
- [ "-a", "127.0.0.1" ],
40
- [ "-c", current_path ],
41
- [ "--user", user ],
42
- [ "--group", user ],
43
- [ "-p", port ],
44
- [ "-P", pid_path ],
45
- [ "-l", "log/mongrel.#{port}.log" ]
46
- ]
42
+ default_options = [
43
+ [ "-d" ],
44
+ [ "-e", "production" ],
45
+ [ "-a", "127.0.0.1" ],
46
+ [ "-c", current_path ],
47
+ [ "--user", user ],
48
+ [ "--group", user ],
49
+ [ "-p", port ],
50
+ [ "-P", pid_path ],
51
+ [ "-l", "log/mongrel.#{port}.log" ]
52
+ ]
47
53
 
48
- default_options << [ "-S", mongrel_config_script ] if mongrel_config_script
54
+ default_options << [ "-S", mongrel_config_script ] if mongrel_config_script
49
55
 
50
- start_options = default_options.collect { |a| a.join(" ") }.join(" ")
51
- #start_options = "-d -e production -a 127.0.0.1 -c #{current_path} --user #{user} --group #{user} -p #{port} -P #{pid_path} -l log/mongrel.#{port}.log"
52
- stop_options = "-p #{port} -P #{pid_path}"
56
+ start_options = default_options.collect { |a| a.join(" ") }.join(" ")
57
+ #start_options = "-d -e production -a 127.0.0.1 -c #{current_path} --user #{user} --group #{user} -p #{port} -P #{pid_path} -l log/mongrel.#{port}.log"
58
+ stop_options = "-p #{port} -P #{pid_path}"
53
59
 
54
- processes << { :port => port, :start_options => start_options, :stop_options => stop_options, :name => "/usr/bin/mongrel_rails", :pid_path => pid_path }
55
- end
60
+ processes << { :port => port, :start_options => start_options, :stop_options => stop_options, :name => "/usr/bin/mongrel_rails", :pid_path => pid_path }
61
+ end
62
+
63
+ set :processes, processes
56
64
 
57
- set :processes, processes
65
+ put template.load("mongrel/mongrel_cluster.monitrc.erb"), "/tmp/#{mongrel_application}.monitrc"
66
+ sudo "install -o root /tmp/#{mongrel_application}.monitrc #{monit_conf_dir}/#{mongrel_application}.monitrc"
67
+ end
68
+
69
+ end
58
70
 
59
- put template.load("mongrel/mongrel_cluster.monitrc.erb"), "/tmp/mongrel_cluster_#{application}.monitrc"
60
- sudo "install -o root /tmp/mongrel_cluster_#{application}.monitrc #{monit_conf_dir}/mongrel_cluster_#{application}.monitrc"
61
71
  end
62
72
 
63
73
  end