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
data/lib/recipes/mysql.rb CHANGED
@@ -1,24 +1,28 @@
1
1
  # Mysql recipes
2
2
  namespace :mysql do
3
3
 
4
- desc <<-DESC
5
- Install mysql monit hooks.
4
+ namespace :monit do
6
5
 
7
- *db_port*: Mysql port. _Defaults to 3306_\n
8
- *mysql_pid_path*: Path to mysql pid file. _Defaults to /var/run/mysqld/mysqld.pid_\n
9
- @set :mysql_pid_path, "/var/run/mysqld/mysqld.pid"@\n
10
- *monit_conf_dir*: Destination for monitrc. _Defaults to "/etc/monit"_\n
11
- @set :monit_conf_dir, "/etc/monit"@\n
12
- DESC
13
- task :install_monit do
6
+ desc <<-DESC
7
+ Install mysql monit hooks.
8
+
9
+ *db_port*: Mysql port. _Defaults to 3306_\n
10
+ *mysql_pid_path*: Path to mysql pid file. _Defaults to /var/run/mysqld/mysqld.pid_\n
11
+ @set :mysql_pid_path, "/var/run/mysqld/mysqld.pid"@\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(:mysql_pid_path, "/var/run/mysqld/mysqld.pid")
19
+ fetch_or_default(:db_port, 3306)
20
+ fetch_or_default(:monit_conf_dir, "/etc/monit")
14
21
 
15
- # Settings
16
- fetch_or_default(:mysql_pid_path, "/var/run/mysqld/mysqld.pid")
17
- fetch_or_default(:db_port, 3306)
18
- fetch_or_default(:monit_conf_dir, "/etc/monit")
22
+ put template.load("mysql/mysql.monitrc.erb", binding), "/tmp/mysql.monitrc"
23
+ run_via "install -o root /tmp/mysql.monitrc #{monit_conf_dir}/mysql.monitrc"
24
+ end
19
25
 
20
- put template.load("mysql/mysql.monitrc.erb", binding), "/tmp/mysql.monitrc"
21
- run_via "install -o root /tmp/mysql.monitrc #{monit_conf_dir}/mysql.monitrc"
22
26
  end
23
27
 
24
28
  desc <<-DESC
@@ -28,9 +32,9 @@ namespace :mysql do
28
32
  *db_user*: Database user (application).\n
29
33
  *db_pass*: Database password (application).\n
30
34
  *mysql_grant_locations*: Grant locations. _Defaults to localhost_\n
31
- @set :grant_locations, [ "localhost", "192.168.1.111" ]@\n
35
+ @set :mysql_grant_locations, [ "localhost", "192.168.1.111" ]@\n
32
36
  *mysql_grant_priv_type*: Grant privilege types. _Defaults to ALL_\n
33
- @set :grant_priv_type, "ALL"@\n
37
+ @set :mysql_grant_priv_type, "ALL"@\n
34
38
  *mysql_admin_password*: Mysql admin password (to use to connect). Defaults to password prompt.\n
35
39
  @set :mysql_admin_password, prompt.password('Mysql admin password: '))@
36
40
  DESC
data/lib/recipes/nginx.rb CHANGED
@@ -1,49 +1,57 @@
1
1
  # Nginx recipes
2
2
  namespace :nginx do
3
3
 
4
- desc <<-DESC
5
- Install nginx monit hooks.
4
+ namespace :monit do
5
+
6
+ desc <<-DESC
7
+ Install nginx monit hooks.
6
8
 
7
- *nginx_pid_path*: Path to nginx pid file. _Defaults to /var/run/nginx.pid_\n
8
- @set :nginx_pid_path, "/var/run/nginx.pid"@\n
9
- *monit_conf_dir*: Destination for monitrc. _Defaults to "/etc/monit"_\n
10
- @set :monit_conf_dir, "/etc/monit"@\n
11
- DESC
12
- task :install_monit do
13
-
14
- # Settings
15
- fetch_or_default(:nginx_pid_path, "/var/run/nginx.pid")
16
- fetch_or_default(:monit_conf_dir, "/etc/monit")
17
-
18
- put template.load("nginx/nginx.monitrc.erb", binding), "/tmp/nginx.monitrc"
19
- run_via "install -o root /tmp/nginx.monitrc #{monit_conf_dir}/nginx.monitrc"
9
+ *nginx_pid_path*: Path to nginx pid file. _Defaults to /var/run/nginx.pid_\n
10
+ @set :nginx_pid_path, "/var/run/nginx.pid"@\n
11
+ *monit_conf_dir*: Destination for monitrc. _Defaults to "/etc/monit"_\n
12
+ @set :monit_conf_dir, "/etc/monit"@\n
13
+ DESC
14
+ task :install do
15
+
16
+ # Settings
17
+ fetch_or_default(:nginx_pid_path, "/var/run/nginx.pid")
18
+ fetch_or_default(:monit_conf_dir, "/etc/monit")
19
+
20
+ put template.load("nginx/nginx.monitrc.erb", binding), "/tmp/nginx.monitrc"
21
+ run_via "install -o root /tmp/nginx.monitrc #{monit_conf_dir}/nginx.monitrc"
22
+ end
23
+
20
24
  end
21
25
 
22
- desc <<-DESC
23
- Create and update the nginx vhost include.
26
+ namespace :mongrel do
27
+ desc <<-DESC
28
+ Create and update the nginx vhost include.
24
29
 
25
- *mongrel_size*: Number of mongrels.\n
26
- @set :mongrel_size, 3@\n
27
- *mongrel_port*: Starting port for mongrels.\n
28
- If there are 3 mongrels with port 9000, then instances will be at 9000, 9001, and 9002\n
29
- @set :mongrel_port, 9000@\n
30
- *domain_name*: Domain name for nginx virtual host, (without www prefix).\n
31
- @set :domain_name, "foo.com"@
32
- DESC
33
- task :setup_mongrel do
34
-
35
- # Settings
36
- fetch(:mongrel_size)
37
- fetch(:mongrel_port)
38
- fetch(:domain_name)
39
-
40
- set :ports, (0...mongrel_size).collect { |i| mongrel_port + i }
41
- set :public_path, current_path + "/public"
42
-
43
- run "mkdir -p #{shared_path}/config"
44
- put template.load("nginx/nginx_vhost.conf.erb"), "/tmp/nginx_#{application}.conf"
45
-
46
- sudo "install -o root /tmp/nginx_#{application}.conf /etc/nginx/vhosts/#{application}.conf"
30
+ *mongrel_application*: Mongrel application. _Defaults to <tt>:application</tt>_
31
+ *mongrel_size*: Number of mongrels.\n
32
+ @set :mongrel_size, 3@\n
33
+ *mongrel_port*: Starting port for mongrels.\n
34
+ If there are 3 mongrels with port 9000, then instances will be at 9000, 9001, and 9002\n
35
+ @set :mongrel_port, 9000@\n
36
+ *domain_name*: Domain name for nginx virtual host, (without www prefix).\n
37
+ @set :domain_name, "foo.com"@
38
+ DESC
39
+ task :setup do
40
+
41
+ # Settings
42
+ fetch(:mongrel_size)
43
+ fetch(:mongrel_port)
44
+ fetch(:domain_name)
45
+ fetch_or_default(:mongrel_application, fetch(:application))
46
+
47
+ set :ports, (0...mongrel_size).collect { |i| mongrel_port + i }
48
+ set :public_path, current_path + "/public"
49
+
50
+ run "mkdir -p #{shared_path}/config"
51
+ put template.load("nginx/nginx_vhost.conf.erb"), "/tmp/nginx_#{mongrel_application}.conf"
52
+
53
+ sudo "install -o root /tmp/nginx_#{mongrel_application}.conf /etc/nginx/vhosts/#{mongrel_application}.conf"
54
+ end
47
55
  end
48
56
 
49
57
  end
data/lib/recipes/rails.rb CHANGED
@@ -23,6 +23,16 @@ namespace :rails do
23
23
  fetch_or_default(:db_host, nil)
24
24
  fetch_or_default(:db_socket, nil)
25
25
 
26
+ unless db_host.blank?
27
+ set :db_connect_type, "host"
28
+ set :db_connect, db_host
29
+ end
30
+
31
+ unless db_socket.blank?
32
+ set :db_connect_type, "socket"
33
+ set :db_connect, db_socket
34
+ end
35
+
26
36
  run "mkdir -p #{shared_path}/config"
27
37
  put template.load("rails/database.yml.erb"), "#{shared_path}/config/database.yml"
28
38
  end
@@ -1,19 +1,23 @@
1
1
  # Sphinx recipes
2
2
  namespace :sphinx do
3
3
 
4
- desc <<-DESC
5
- Create monit configuration for sphinx.\n
6
- *monit_conf_dir*: Destination for monitrc. _Defaults to "/etc/monit"_\n
7
- *sphinx_pid_path*: Location for sphinx pid. _Defaults to "[shared_path]/pids/searchd.pid"_\n
8
- DESC
9
- task :setup_monit do
4
+ namespace :monit do
5
+
6
+ desc <<-DESC
7
+ Create monit configuration for sphinx.\n
8
+ *monit_conf_dir*: Destination for monitrc. _Defaults to "/etc/monit"_\n
9
+ *sphinx_pid_path*: Location for sphinx pid. _Defaults to "[shared_path]/pids/searchd.pid"_\n
10
+ DESC
11
+ task :setup do
12
+
13
+ # Settings
14
+ fetch_or_default(:monit_conf_dir, "/etc/monit")
15
+ fetch_or_default(:sphinx_pid_path, "#{shared_path}/pids/searchd.pid")
10
16
 
11
- # Settings
12
- fetch_or_default(:monit_conf_dir, "/etc/monit")
13
- fetch_or_default(:sphinx_pid_path, "#{shared_path}/pids/searchd.pid")
17
+ put template.load("sphinx/sphinx.monitrc.erb"), "/tmp/sphinx_#{application}.monitrc"
18
+ sudo "install -o root /tmp/sphinx_#{application}.monitrc #{monit_conf_dir}/sphinx_#{application}.monitrc"
19
+ end
14
20
 
15
- put template.load("sphinx/sphinx.monitrc.erb"), "/tmp/sphinx_#{application}.monitrc"
16
- sudo "install -o root /tmp/sphinx_#{application}.monitrc #{monit_conf_dir}/sphinx_#{application}.monitrc"
17
21
  end
18
22
 
19
23
  desc <<-DESC
@@ -12,11 +12,11 @@
12
12
  #
13
13
 
14
14
  set -e
15
- trap ERROR ERR
16
15
 
17
16
  CONF_DIR=<%= mongrel_config_dir %>
18
17
  PID_DIR=<%= mongrel_pid_dir %>
19
18
  USER=<%= user %>
19
+ CMD=<%= mongrel_cluster_command %>
20
20
 
21
21
  RETVAL=0
22
22
 
@@ -26,7 +26,7 @@ fail() {
26
26
  }
27
27
 
28
28
  # Gracefully exit if the controller is missing.
29
- which mongrel_cluster_ctl >/dev/null || fail "mongrel_cluster_ctl not found"
29
+ which $CMD >/dev/null || fail "$CMD not found"
30
30
 
31
31
  # Go no further if config directory is missing.
32
32
  [ -d "$CONF_DIR" ] || fail "$CONF_DIR not found"
@@ -37,19 +37,19 @@ case "$1" in
37
37
  mkdir -p $PID_DIR
38
38
  chown $USER:$USER $PID_DIR
39
39
 
40
- mongrel_cluster_ctl start -c $CONF_DIR --clean
40
+ $CMD start -c $CONF_DIR --clean
41
41
  RETVAL=$?
42
42
  ;;
43
43
  stop)
44
- mongrel_cluster_ctl stop -c $CONF_DIR
44
+ $CMD stop -c $CONF_DIR
45
45
  RETVAL=$?
46
46
  ;;
47
47
  restart)
48
- mongrel_cluster_ctl restart -c $CONF_DIR
48
+ $CMD restart -c $CONF_DIR
49
49
  RETVAL=$?
50
50
  ;;
51
51
  status)
52
- mongrel_cluster_ctl status -c $CONF_DIR
52
+ $CMD status -c $CONF_DIR
53
53
  RETVAL=$?
54
54
  ;;
55
55
  *)
@@ -1,7 +1,7 @@
1
1
  <% processes.each do |process| %>
2
2
 
3
- check process mongrel_cluster_<%= application %>_<%= process[:port] %> with pidfile <%= process[:pid_path] %>
4
- group mongrel_cluster_<%= application %>
3
+ check process <%= mongrel_application %>_<%= process[:port] %> with pidfile <%= process[:pid_path] %>
4
+ group <%= mongrel_application %>
5
5
  start program = "<%= process[:name] %> start <%= process[:start_options] %>"
6
6
  stop program = "<%= process[:name] %> stop <%= process[:stop_options] %>"
7
7
  if failed host 127.0.0.1 port <%= process[:port] %> protocol http
@@ -8,4 +8,4 @@ pid_file: <%= mongrel_pid_dir %>/mongrel.pid
8
8
  servers: <%= mongrel_size %>
9
9
  user: <%= user %>
10
10
  group: <%= user %>
11
- config_script: <%= mongrel_config_script unless mongrel_config_script.blank? %>
11
+ <% mongrel_config_options.each do |k, v| %><%= "#{k}: #{v}\n" %><% end %>
@@ -7,7 +7,7 @@
7
7
  # * Redirects domain.com to www.domain.com (IMO should be the other way around; www is deprecated)
8
8
  #
9
9
 
10
- upstream mongrel-cluster-<%= application %> {
10
+ upstream <%= mongrel_application %> {
11
11
  <% ports.each do |port| %>
12
12
  server 127.0.0.1:<%= port %>;
13
13
  <% end %>
@@ -20,8 +20,10 @@ server {
20
20
  # Set the max size for file uploads to 50Mb
21
21
  client_max_body_size 50M;
22
22
 
23
+ <% unless domain_name.blank? or domain_name == "localhost" %>
23
24
  # sets the domain[s] that this vhost server requests for
24
25
  server_name www.<%= domain_name %>;
26
+ <% end %>
25
27
 
26
28
  # doc root
27
29
  root <%= public_path %>;
@@ -53,7 +55,7 @@ server {
53
55
  # For iphone unique url
54
56
  if ($http_user_agent ~* "(iPhone|iPod)") {
55
57
  rewrite ^/$ /iphone break;
56
- proxy_pass http://mongrel-cluster-<%= application %>;
58
+ proxy_pass http://<%= mongrel_application %>;
57
59
  break;
58
60
  }
59
61
 
@@ -74,7 +76,7 @@ server {
74
76
  }
75
77
 
76
78
  if (!-f $request_filename) {
77
- proxy_pass http://mongrel-cluster-<%= application %>;
79
+ proxy_pass http://<%= mongrel_application %>;
78
80
  break;
79
81
  }
80
82
  }
@@ -89,7 +91,9 @@ server {
89
91
  }
90
92
  }
91
93
 
94
+ <% unless domain_name.blank? or domain_name == "localhost" %>
92
95
  server {
93
96
  server_name <%= domain_name %>;
94
97
  rewrite ^/(.*) http://www.<%= domain_name %>/$1 permanent;
95
- }
98
+ }
99
+ <% end %>
@@ -4,5 +4,4 @@ production:
4
4
  database: <%= db_name %>
5
5
  username: <%= db_user %>
6
6
  password: <%= db_pass %>
7
- <%= "host: #{db_host}" unless db_host.blank? %>
8
- <%= "socket: #{db_socket}" unless db_socket.blank? %>
7
+ <%= "#{db_connect_type}: #{db_connect}" %>
data/website/index.html CHANGED
@@ -38,7 +38,7 @@
38
38
 
39
39
  <div id="version" class="clickable box" onclick='document.location = "http://rubyforge.org/projects/capitate"; return false'>
40
40
  <p>Get Version</p>
41
- <a href="http://rubyforge.org/projects/capitate" class="numbers">0.2.3</a>
41
+ <a href="http://rubyforge.org/projects/capitate" class="numbers">0.2.5</a>
42
42
  </div>
43
43
 
44
44
  <div id="recipes">
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: capitate
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.3
4
+ version: 0.2.5
5
5
  platform: ""
6
6
  authors:
7
7
  - Gabriel Handford
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2008-02-25 00:00:00 -05:00
12
+ date: 2008-02-29 00:00:00 -05:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -42,19 +42,26 @@ extra_rdoc_files:
42
42
  - docs/recipes/imagemagick.txt
43
43
  - docs/recipes/index.txt
44
44
  - docs/recipes/memcached-centos.txt
45
+ - docs/recipes/memcached-monit.txt
45
46
  - docs/recipes/memcached.txt
46
- - docs/recipes/mongrel_cluster-centos.txt
47
- - docs/recipes/mongrel_cluster.txt
47
+ - docs/recipes/mongrel-cluster-centos.txt
48
+ - docs/recipes/mongrel-cluster-monit.txt
49
+ - docs/recipes/mongrel-cluster.txt
50
+ - docs/recipes/mongrel.txt
48
51
  - docs/recipes/monit-centos.txt
49
52
  - docs/recipes/monit.txt
50
53
  - docs/recipes/mysql-centos.txt
54
+ - docs/recipes/mysql-monit.txt
51
55
  - docs/recipes/mysql.txt
52
56
  - docs/recipes/nginx-centos.txt
57
+ - docs/recipes/nginx-mongrel.txt
58
+ - docs/recipes/nginx-monit.txt
53
59
  - docs/recipes/nginx.txt
54
60
  - docs/recipes/rails.txt
55
61
  - docs/recipes/ruby-centos.txt
56
62
  - docs/recipes/ruby.txt
57
63
  - docs/recipes/sphinx-centos.txt
64
+ - docs/recipes/sphinx-monit.txt
58
65
  - docs/recipes/sphinx.txt
59
66
  - website/index.txt
60
67
  files:
@@ -77,23 +84,31 @@ files:
77
84
  - docs/recipes/imagemagick.txt
78
85
  - docs/recipes/index.txt
79
86
  - docs/recipes/memcached-centos.txt
87
+ - docs/recipes/memcached-monit.txt
80
88
  - docs/recipes/memcached.txt
81
- - docs/recipes/mongrel_cluster-centos.txt
82
- - docs/recipes/mongrel_cluster.txt
89
+ - docs/recipes/mongrel-cluster-centos.txt
90
+ - docs/recipes/mongrel-cluster-monit.txt
91
+ - docs/recipes/mongrel-cluster.txt
92
+ - docs/recipes/mongrel.txt
83
93
  - docs/recipes/monit-centos.txt
84
94
  - docs/recipes/monit.txt
85
95
  - docs/recipes/mysql-centos.txt
96
+ - docs/recipes/mysql-monit.txt
86
97
  - docs/recipes/mysql.txt
87
98
  - docs/recipes/nginx-centos.txt
99
+ - docs/recipes/nginx-mongrel.txt
100
+ - docs/recipes/nginx-monit.txt
88
101
  - docs/recipes/nginx.txt
89
102
  - docs/recipes/rails.txt
90
103
  - docs/recipes/ruby-centos.txt
91
104
  - docs/recipes/ruby.txt
92
105
  - docs/recipes/sphinx-centos.txt
106
+ - docs/recipes/sphinx-monit.txt
93
107
  - docs/recipes/sphinx.txt
94
108
  - lib/capitate.rb
95
109
  - lib/capitate/cap_ext/connections.rb
96
110
  - lib/capitate/cap_ext/extension_proxy.rb
111
+ - lib/capitate/cap_ext/roles.rb
97
112
  - lib/capitate/cap_ext/run_via.rb
98
113
  - lib/capitate/cap_ext/variables.rb
99
114
  - lib/capitate/plugins/base.rb