capitate 0.3.2 → 0.3.3

Sign up to get free protection for your applications and to get access to all the features.
data/History.txt CHANGED
@@ -1,3 +1,11 @@
1
+ == 0.3.3 2008-04-29
2
+
3
+ * Adding merb init script (for Centos)
4
+ * Adding merb monit confs
5
+ * Adding merb logrotate
6
+ * Created generic nginx vhost template
7
+ * Deprecated rails:setup for active_record:setup (for merb setup)
8
+
1
9
  == 0.3.2 2008-04-03
2
10
 
3
11
  * Adding hostname helper (utils.hostname)
data/Manifest.txt CHANGED
@@ -26,12 +26,14 @@ lib/capitate/recipes.rb
26
26
  lib/capitate/task_node.rb
27
27
  lib/capitate/version.rb
28
28
  lib/deployment/centos-5.1-64-web/install.rb
29
+ lib/recipes/active_record.rb
29
30
  lib/recipes/backgroundrb.rb
30
31
  lib/recipes/centos/backgroundjob.rb
31
32
  lib/recipes/centos/backgroundrb.rb
32
33
  lib/recipes/centos/centos.rb
33
34
  lib/recipes/centos/imagemagick.rb
34
35
  lib/recipes/centos/memcached.rb
36
+ lib/recipes/centos/merb.rb
35
37
  lib/recipes/centos/mongrel_cluster.rb
36
38
  lib/recipes/centos/monit.rb
37
39
  lib/recipes/centos/mysql.rb
@@ -41,6 +43,7 @@ lib/recipes/centos/sphinx.rb
41
43
  lib/recipes/docs.rb
42
44
  lib/recipes/logrotate/backgroundjob.rb
43
45
  lib/recipes/logrotate/backgroundrb.rb
46
+ lib/recipes/logrotate/merb.rb
44
47
  lib/recipes/logrotate/mongrel_cluster.rb
45
48
  lib/recipes/logrotate/monit.rb
46
49
  lib/recipes/logrotate/mysql.rb
@@ -54,6 +57,7 @@ lib/recipes/monit/backgroundjob.rb
54
57
  lib/recipes/monit/backgroundrb.rb
55
58
  lib/recipes/monit/database.rb
56
59
  lib/recipes/monit/memcached.rb
60
+ lib/recipes/monit/merb.rb
57
61
  lib/recipes/monit/mongrel_cluster.rb
58
62
  lib/recipes/monit/mysql.rb
59
63
  lib/recipes/monit/nginx.rb
@@ -75,6 +79,8 @@ lib/templates/logrotated/conf.erb
75
79
  lib/templates/memcached/memcached.initd.centos.erb
76
80
  lib/templates/memcached/memcached.monitrc.erb
77
81
  lib/templates/memcached/memcached.yml.erb
82
+ lib/templates/merb/merb.initd.centos.erb
83
+ lib/templates/merb/merb.monitrc.erb
78
84
  lib/templates/mongrel/mongrel_cluster.initd.centos.erb
79
85
  lib/templates/mongrel/mongrel_cluster.monitrc.erb
80
86
  lib/templates/mongrel/mongrel_cluster.yml.erb
@@ -89,6 +95,7 @@ lib/templates/nginx/nginx.conf.erb
89
95
  lib/templates/nginx/nginx.initd.centos.erb
90
96
  lib/templates/nginx/nginx.monitrc.erb
91
97
  lib/templates/nginx/nginx_vhost.conf.erb
98
+ lib/templates/nginx/nginx_vhost_generic.conf.erb
92
99
  lib/templates/rails/database.yml.erb
93
100
  lib/templates/ruby/fix_openssl.sh
94
101
  lib/templates/sphinx/sphinx.conf.erb
@@ -116,10 +116,11 @@ module Capitate::Plugins::Utils
116
116
  # utils.hostname => "localhost.localdomain"
117
117
  #
118
118
  def hostname
119
+ hostname = nil
119
120
  run "hostname" do |channel, stream, data|
120
- return data.chomp
121
+ hostname = data.chomp
121
122
  end
122
- nil
123
+ hostname
123
124
  end
124
125
 
125
126
  # Append data to a file.
@@ -2,7 +2,7 @@ module Capitate #:nodoc:
2
2
  module VERSION #:nodoc:
3
3
  MAJOR = 0
4
4
  MINOR = 3
5
- TINY = 2
5
+ TINY = 3
6
6
 
7
7
  STRING = [MAJOR, MINOR, TINY].join('.')
8
8
  end
@@ -0,0 +1,65 @@
1
+ namespace :active_record do
2
+
3
+ desc <<-DESC
4
+ Create (ActiveRecord) database yaml in shared path.
5
+ Note: If both @:db_host@ and @:db_socket@ are used, @db_socket@ wins.
6
+
7
+ <dl>
8
+ <dt>db_name</dt>
9
+ <dd>Database name.</dd>
10
+ <dd>@set :db_name, "app_db_name"@</dd>
11
+
12
+ <dt>db_user</dt>
13
+ <dd>Database user.</dd>
14
+ <dd>@set :db_user, "app_db_user"@</dd>
15
+
16
+ <dt>db_pass</dt>
17
+ <dd>Database password.</dd>
18
+ <dd>@set :db_pass, "the_password"@</dd>
19
+
20
+ <dt>db_host</dt>
21
+ <dd>Database host (can be nil, if you are using socket).</dd>
22
+ <dd class="default">Defaults to @nil@</dd>
23
+
24
+ <dt>db_socket</dt>
25
+ <dd>Database socket (can be nil, if you are using host).</dd>
26
+ <dd class="default">Defaults to @nil@</dd>
27
+ <dd>@set :db_socket, "/var/lib/mysql/mysql.sock"@</dd>
28
+
29
+ <dt>database_yml_template</dt>
30
+ <dd>Path to database yml erb template.
31
+ <dd class="default">Defaults to @rails/database.yml.erb@ (in this GEM)</dd>
32
+ </dl>
33
+
34
+ "Source":#{link_to_source(__FILE__)}
35
+ DESC
36
+ task :setup, :roles => :app do
37
+
38
+ # Settings
39
+ fetch(:db_name)
40
+ fetch(:db_user)
41
+ fetch(:db_pass)
42
+ fetch_or_default(:db_host, nil)
43
+ fetch_or_default(:db_socket, nil)
44
+ fetch_or_default(:database_yml_template, "rails/database.yml.erb")
45
+
46
+ unless db_host.blank?
47
+ set :db_connect_type, "host"
48
+ set :db_connect, db_host
49
+ end
50
+
51
+ unless db_socket.blank?
52
+ set :db_connect_type, "socket"
53
+ set :db_connect, db_socket
54
+ end
55
+
56
+ run "mkdir -p #{shared_path}/config"
57
+ put template.load(database_yml_template), "#{shared_path}/config/database.yml"
58
+ end
59
+
60
+ desc "Make symlink for database yaml"
61
+ task :update_code do
62
+ run "ln -nfs #{shared_path}/config/database.yml #{release_path}/config/database.yml"
63
+ end
64
+
65
+ end
@@ -0,0 +1,49 @@
1
+ namespace :merb do
2
+ namespace :centos do
3
+
4
+ desc <<-DESC
5
+ Setup merb.
6
+
7
+ <dl>
8
+ <dt>merb_command_path</dt>
9
+ <dd>The path for merb startup command</dd>
10
+ <dd class="default">Defaults to @merb@</dd>
11
+
12
+ <dt>merb_nodes</dt>
13
+ <dd>Number of merb daemons to run</dd>
14
+ <dd>@set :merb_nodes, 3@</dd>
15
+
16
+ <dt>merb_port</dt>
17
+ <dd>Starting port for merb nodes. If there are 3 merb nodes with port 9000,
18
+ then instances will be at 9000, 9001, and 9002</dd>
19
+ <dd>@set :merb_port, 9000@</dd>
20
+
21
+ <dt>merb_root</dt>
22
+ <dd>Directory for merb root</dd>
23
+ <dd class="default">Defaults to @\#{current_path}@</dd>
24
+
25
+ <dt>merb_pid_path</dt>
26
+ <dd>Path for merb pids</dd>
27
+ <dd class="default">Defaults to @\#{shared_path}/pids/merb.pid@</dd>
28
+ </dl>
29
+ "Source":#{link_to_source(__FILE__)}
30
+ DESC
31
+ task :setup do
32
+
33
+ # Settings
34
+ fetch(:merb_nodes)
35
+ fetch(:merb_port)
36
+ fetch_or_default(:merb_command_path, "merb")
37
+ fetch_or_default(:merb_pid_path, "#{shared_path}/pids/merb.pid")
38
+ fetch_or_default(:merb_root, current_path)
39
+ fetch_or_default(:merb_application, "merb_#{application}")
40
+
41
+ fetch_or_default(:merb_initscript_name, "merb_#{application}")
42
+
43
+ utils.install_template("merb/merb.initd.centos.erb", "/etc/init.d/#{merb_initscript_name}")
44
+ run_via "/sbin/chkconfig --level 345 #{merb_initscript_name} on"
45
+ end
46
+
47
+ end
48
+
49
+ end
@@ -8,6 +8,10 @@ namespace :mongrel do
8
8
  Create mongrel cluster.
9
9
 
10
10
  <dl>
11
+ <dt>mongrel_application</dt>
12
+ <dd>Name of mongrel application</dd>
13
+ <dd>@set :mongrel_application, "mongrel_cluster_\#{application}"@</dd>
14
+
11
15
  <dt>mongrel_size</dt><dd>Number of mongrels</dd>
12
16
  <dd>@set :mongrel_size, 3@</dd>
13
17
 
@@ -0,0 +1,25 @@
1
+ namespace :merb do
2
+
3
+ namespace :logrotate do
4
+ desc <<-DESC
5
+ Install logrotated conf for merb.
6
+
7
+ <dl>
8
+ <dt>merb_logrotate_path</dt>
9
+ <dd>Merb logrotate path</dd>
10
+ <dd class="default">Defaults to @\#{shared_path}/log/merb_*.log@</dd>
11
+ </dl>
12
+ "Source":#{link_to_source(__FILE__)}
13
+ DESC
14
+ task :install do
15
+ fetch_or_default(:merb_logrotate_path, "#{shared_path}/log/merb_*.log")
16
+
17
+ set :logrotate_name, "merb_#{application}"
18
+ set :logrotate_log_path, merb_logrotate_path
19
+ set :logrotate_options, [ { :rotate => 7 }, :daily, :missingok, :notifempty, :copytruncate ]
20
+
21
+ logrotated.install_conf
22
+ end
23
+ end
24
+
25
+ end
@@ -0,0 +1,63 @@
1
+
2
+ namespace :merb do
3
+
4
+ namespace :monit do
5
+
6
+ desc <<-DESC
7
+ Create monit configuration for merb.
8
+
9
+ "Source":#{link_to_source(__FILE__)}
10
+ DESC
11
+ task :setup do
12
+
13
+ # Settings
14
+ fetch(:merb_nodes)
15
+ fetch(:merb_port)
16
+ fetch_or_default(:merb_application, "merb_#{application}")
17
+ fetch_or_default(:merb_initscript_name, "merb_#{application}")
18
+ fetch_or_default(:monit_conf_dir, "/etc/monit")
19
+
20
+ fetch_or_default(:merb_pid_dir, "#{shared_path}/pids")
21
+
22
+ processes = []
23
+ ports = (0...merb_nodes).collect { |i| merb_port + i }
24
+ ports.each do |port|
25
+
26
+ pid_path = "#{merb_pid_dir}/#{merb_application}.#{port}.pid"
27
+
28
+ start = "/etc/init.d/#{merb_initscript_name} start_only #{port}"
29
+ stop = "/etc/init.d/#{merb_initscript_name} stop_only #{port}"
30
+
31
+ processes << { :port => port, :start => start, :stop => stop, :pid_path => pid_path }
32
+ end
33
+
34
+ set :processes, processes
35
+
36
+ put template.load("merb/merb.monitrc.erb"), "/tmp/#{merb_application}.monitrc"
37
+ sudo "install -o root /tmp/#{merb_application}.monitrc #{monit_conf_dir}/#{merb_application}.monitrc"
38
+ end
39
+
40
+ desc "Restart merb (for application)"
41
+ task :restart do
42
+ fetch_or_default(:monit_bin_path, "monit")
43
+ fetch_or_default(:merb_application, "merb_#{application}")
44
+ sudo "#{monit_bin_path} -g #{merb_application} restart all"
45
+ end
46
+
47
+ desc "Start merb (for application)"
48
+ task :start do
49
+ fetch_or_default(:monit_bin_path, "monit")
50
+ fetch_or_default(:merb_application, "merb_#{application}")
51
+ sudo "#{monit_bin_path} -g #{merb_application} start all"
52
+ end
53
+
54
+ desc "Stop merb (for application)"
55
+ task :stop do
56
+ fetch_or_default(:monit_bin_path, "monit")
57
+ fetch_or_default(:merb_application, "merb_#{application}")
58
+ sudo "#{monit_bin_path} -g #{merb_application} stop all"
59
+ end
60
+
61
+ end
62
+
63
+ end
@@ -1,4 +1,3 @@
1
- # Create init script
2
1
  namespace :mongrel do
3
2
 
4
3
  namespace :cluster do
@@ -23,12 +22,13 @@ namespace :mongrel do
23
22
  fetch_or_default(:mongrel_bin_path, "/usr/bin/mongrel_rails")
24
23
  fetch_or_default(:mongrel_config_script, nil)
25
24
  fetch_or_default(:monit_conf_dir, "/etc/monit")
25
+ fetch_or_default(:mongrel_pid_dir, "#{shared_path}/pids")
26
26
 
27
27
  processes = []
28
28
  ports = (0...mongrel_size).collect { |i| mongrel_port + i }
29
29
  ports.each do |port|
30
30
 
31
- pid_path = "#{shared_path}/pids/#{mongrel_application}.#{port}.pid"
31
+ pid_path = "#{mongrel_pid_dir}/#{mongrel_application}.#{port}.pid"
32
32
 
33
33
  default_options = [
34
34
  [ "-d" ],
data/lib/recipes/nginx.rb CHANGED
@@ -1,9 +1,53 @@
1
1
  # Nginx recipes
2
2
  namespace :nginx do
3
3
 
4
+ namespace :host do
5
+
6
+ desc <<-DESC
7
+ Generate the nginx vhost include.
8
+
9
+ <dl>
10
+ <dt>nginx_upstream_name</dt>
11
+ <dd>Application name (for upstream definition).</dd>
12
+ <dd class="default">Defaults to @:application@</dd>
13
+
14
+ <dt>nginx_upstream_size</dt>
15
+ <dd>Number of nodes for upstream.</dd>
16
+ <dd>@set :nginx_upstream_size, 3@</dd>
17
+
18
+ <dt>nginx_upstream_port</dt>
19
+ <dd>Starting port for upstream. If there are 3 nodes with port 9000, then instances will be at 9000, 9001, and 9002</dd>
20
+ <dd>@set :nginx_upstream_port, 9000@</dd>
21
+
22
+ <dt>domain_name</dt>: Domain name for nginx virtual host, (without www prefix).</dd>
23
+ <dd>@set :domain_name, "foo.com"@</dd>
24
+ </dl>
25
+
26
+ "Source":#{link_to_source(__FILE__)}
27
+ DESC
28
+ task :setup do
29
+
30
+ # Settings
31
+ fetch_or_default(:nginx_upstream_name, fetch(:application))
32
+ fetch(:nginx_upstream_size)
33
+ fetch(:nginx_upstream_port)
34
+
35
+ set :ports, (0...nginx_upstream_size).collect { |i| nginx_upstream_port + i }
36
+ set :public_path, current_path + "/public"
37
+
38
+ run "mkdir -p #{shared_path}/config"
39
+ put template.load("nginx/nginx_vhost_generic.conf.erb"), "/tmp/nginx_#{nginx_upstream_name}.conf"
40
+
41
+ sudo "install -o root /tmp/nginx_#{nginx_upstream_name}.conf /etc/nginx/vhosts/#{nginx_upstream_name}.conf"
42
+ end
43
+
44
+ end
45
+
4
46
  namespace :mongrel do
5
47
  desc <<-DESC
6
48
  Generate the nginx vhost include (for a mongrel setup).
49
+
50
+ *THIS IS DEPRECATED*: Use @nginx:host:setup@
7
51
 
8
52
  <dl>
9
53
  <dt>mongrel_application</dt>
data/lib/recipes/rails.rb CHANGED
@@ -4,17 +4,19 @@ namespace :rails do
4
4
  desc <<-DESC
5
5
  Create database yaml in shared path. Note: If both @:db_host@ and @:db_socket@ are used, @db_socket@ wins.
6
6
 
7
+ *DEPRECATED*: Use @active_record:setup@
8
+
7
9
  <dl>
8
10
  <dt>db_name</dt>
9
- <dd>Database name (rails).</dd>
11
+ <dd>Database name.</dd>
10
12
  <dd>@set :db_name, "app_db_name"@</dd>
11
13
 
12
14
  <dt>db_user</dt>
13
- <dd>Database user (rails).</dd>
15
+ <dd>Database user.</dd>
14
16
  <dd>@set :db_user, "app_db_user"@</dd>
15
17
 
16
18
  <dt>db_pass</dt>
17
- <dd>Database password (rails).</dd>
19
+ <dd>Database password.</dd>
18
20
  <dd>@set :db_pass, "the_password"@</dd>
19
21
 
20
22
  <dt>db_host</dt>
@@ -32,8 +32,7 @@ namespace :sphinx do
32
32
  fetch_or_default(:sphinx_conf_root, "#{current_path}/config")
33
33
  fetch_or_default(:sphinx_index_root, "#{shared_path}/var/index")
34
34
  fetch_or_default(:sphinx_log_root, "#{shared_path}/log")
35
- fetch_or_default(:sphinx_pid_path, "#{shared_path}/pids/searchd.pid")
36
- fetch_or_default(:sphinx_hostname, Proc.new { utils.hostname }) # Runs if needed
35
+ fetch_or_default(:sphinx_pid_path, "#{shared_path}/pids/searchd.pid")
37
36
 
38
37
  fetch_or_set(:sphinx_db_user, :db_user)
39
38
  fetch_or_set(:sphinx_db_pass, :db_pass)
@@ -42,7 +41,7 @@ namespace :sphinx do
42
41
  fetch_or_set(:sphinx_db_host, :db_host)
43
42
  fetch_or_default(:sphinx_conf_host, "127.0.0.1")
44
43
 
45
- put template.load(sphinx_conf_template), sphinx_conf_path
44
+ put(template.load(sphinx_conf_template), sphinx_conf_path)
46
45
  end
47
46
 
48
47
  desc "Make symlink for sphinx conf"
@@ -0,0 +1,123 @@
1
+ #!/bin/bash
2
+ #
3
+ # Copyright (c) 2008 Gabriel Handford, gabrielh@gmail.com
4
+ #
5
+ # merb_<%= application %> Startup script for Merb (<%= application %>)
6
+ #
7
+ # chkconfig: - 85 15
8
+ # description: merb_<%= application %> Merb runtime for <%= application %>
9
+ #
10
+ # WARNING: Relies on some patches:
11
+ # This requires a couple of submitted patches to merb-core (on version 0.9.2),
12
+ # for correct pid file and kill handling.
13
+ #
14
+ # Also have to cd into the project before starting merb. There are some issues with plugins
15
+ # and Merb.root
16
+ #
17
+
18
+ # Source function library
19
+ . /etc/rc.d/init.d/functions
20
+
21
+ RETVAL=0
22
+
23
+ NAME="merb_<%= application %>"
24
+ USER="<%= user %>"
25
+ GROUP="<%= user %>"
26
+
27
+ PID_PATH="<%= merb_pid_path %>"
28
+ NODES=<%= merb_nodes %>
29
+ PORT=<%= merb_port %>
30
+ ROOT_DIR="<%= merb_root %>"
31
+
32
+ CMD="<%= merb_command_path %>"
33
+ CMD_OPTIONS="-u $USER -G $GROUP -P $PID_PATH -m $ROOT_DIR -e production"
34
+
35
+ RETVAL=0
36
+
37
+ start() {
38
+ echo -n $"Starting $NAME: "
39
+ cd $ROOT_DIR
40
+ $CMD $CMD_OPTIONS -c $NODES -p $PORT
41
+ RETVAL=$?
42
+ [ "$RETVAL" -eq 0 ] && success $"$NAME start" || failure $"$NAME start"
43
+ echo
44
+ return $RETVAL;
45
+ }
46
+
47
+ # Start only a single daemon function ($1=port)
48
+ start_only() {
49
+ cd $ROOT_DIR
50
+ $CMD $CMD_OPTIONS -c 1 -p $1
51
+ }
52
+
53
+ stop() {
54
+ echo -n $"Stopping $NAME: "
55
+ cd $ROOT_DIR
56
+ $CMD $CMD_OPTIONS -c $NODES -p $PORT -K all
57
+ RETVAL=$?
58
+ [ "$RETVAL" -eq 0 ] && success $"$NAME shutdown" || failure $"$NAME shutdown"
59
+ echo
60
+ return $RETVAL;
61
+ }
62
+
63
+ # Stop only a single daemon ($1=port)
64
+ stop_only() {
65
+ cd $ROOT_DIR
66
+ $CMD $CMD_OPTIONS -c 1 -p $PORT -K $1
67
+ }
68
+
69
+ restart() {
70
+ stop
71
+ sleep 1
72
+ start
73
+ }
74
+
75
+ status() {
76
+ echo "Don't know"
77
+ RETVAL=$?
78
+ echo
79
+ return $RETVAL;
80
+ }
81
+
82
+ fail() {
83
+ echo "Failed to start: $1"
84
+ exit 1
85
+ }
86
+
87
+ # Gracefully exit if the controller is missing.
88
+ which $CMD >/dev/null || fail "$CMD not found"
89
+
90
+ case "$1" in
91
+ start)
92
+ start
93
+ ;;
94
+ start_only)
95
+ start_only $2
96
+ ;;
97
+ stop)
98
+ stop
99
+ ;;
100
+ stop_only)
101
+ stop_only $2
102
+ ;;
103
+ restart)
104
+ restart
105
+ ;;
106
+ status)
107
+ status
108
+ ;;
109
+ *)
110
+ echo "Usage: $0"
111
+ echo " "
112
+ echo " start"
113
+ echo " stop"
114
+ echo " restart"
115
+ echo " status"
116
+ echo " start_only [port]"
117
+ echo " stop_only [port]"
118
+ echo " "
119
+ RETVAL=3;
120
+ ;;
121
+ esac
122
+
123
+ exit $RETVAL
@@ -0,0 +1,15 @@
1
+ <% processes.each do |process| %>
2
+
3
+ check process <%= merb_application %>_<%= process[:port] %> with pidfile <%= process[:pid_path] %>
4
+ group <%= merb_application %>
5
+ start program = "<%= process[:start] %>"
6
+ stop program = "<%= process[:stop] %>"
7
+ if failed host 127.0.0.1 port <%= process[:port] %> protocol http
8
+ and request "/" then alert
9
+ if totalmem > 100 Mb then restart
10
+ if cpu is greater than 60% for 2 cycles then alert
11
+ if cpu > 80% for 5 cycles then restart
12
+ if loadavg(5min) greater than 10 for 8 cycles then restart
13
+ if 3 restarts within 5 cycles then timeout
14
+
15
+ <% end %>
@@ -1,4 +1,6 @@
1
1
  #
2
+ # DEPRECATED: USE nginx_vhost_generic.conf.erb (This is here for backwards compatibility)
3
+ #
2
4
  # Nginx virtual host conf
3
5
  #
4
6
  # * Uses cache directory configured for public/cache
@@ -0,0 +1,99 @@
1
+ #
2
+ # Nginx virtual host conf
3
+ #
4
+ # * Uses cache directory configured for public/cache
5
+ # * Re-writes url for iphone user agent to /iphone (so as not to conflict with cache)
6
+ # * TODO-gabe: Same for mobile user agents
7
+ # * Redirects domain.com to www.domain.com (IMO should be the other way around; www is deprecated)
8
+ #
9
+
10
+ upstream <%= nginx_upstream_name %> {
11
+ <% nginx_upstream_ports.each do |port| %>
12
+ server 127.0.0.1:<%= port %>;
13
+ <% end %>
14
+ }
15
+
16
+ server {
17
+ # port to listen on. Can also be set to an IP:PORT.
18
+ listen 80;
19
+
20
+ # Set the max size for file uploads to 50Mb
21
+ client_max_body_size 50M;
22
+
23
+ <% unless domain_name.blank? or domain_name == "localhost" %>
24
+ # sets the domain[s] that this vhost server requests for
25
+ server_name www.<%= domain_name %>;
26
+ <% end %>
27
+
28
+ # doc root
29
+ root <%= public_path %>;
30
+
31
+ # vhost specific access log
32
+ access_log <%= shared_path %>/log/nginx.<%= application %>.access.log main;
33
+
34
+ # this rewrites all the requests to the maintenance.html
35
+ # page if it exists in the doc root. This is for capistrano's
36
+ # disable web task
37
+ if (-f $document_root/system/maintenance.html) {
38
+ rewrite ^(.*)$ /system/maintenance.html last;
39
+ break;
40
+ }
41
+
42
+ location / {
43
+ # Uncomment to allow server side includes so nginx can
44
+ # post-process Rails content
45
+ ## ssi on;
46
+
47
+ proxy_set_header X-Real-IP $remote_addr;
48
+
49
+ # needed for HTTPS
50
+ proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
51
+ proxy_set_header Host $http_host;
52
+ proxy_redirect false;
53
+ proxy_max_temp_file_size 0;
54
+
55
+ # For iphone unique url
56
+ if ($http_user_agent ~* "(iPhone|iPod)") {
57
+ rewrite ^/$ /iphone break;
58
+ proxy_pass http://<%= nginx_upstream %>;
59
+ break;
60
+ }
61
+
62
+ if (-f $request_filename) {
63
+ break;
64
+ }
65
+
66
+ if (-f $document_root/cache/$uri/index.html) {
67
+ rewrite (.*) /cache/$1/index.html break;
68
+ }
69
+
70
+ if (-f $document_root/cache/$uri.html) {
71
+ rewrite (.*) /cache/$1.html break;
72
+ }
73
+
74
+ if (-f $document_root/cache/$uri) {
75
+ rewrite (.*) /cache/$1 break;
76
+ }
77
+
78
+ if (!-f $request_filename) {
79
+ proxy_pass http://<%= nginx_upstream %>;
80
+ break;
81
+ }
82
+ }
83
+
84
+ #error_page 404 /404.html;
85
+
86
+ # redirect server error pages to the static page /50x.html
87
+ #
88
+ error_page 500 502 503 504 /500.html;
89
+ location = /500.html {
90
+ root <%= public_path %>;
91
+ }
92
+ }
93
+
94
+ <% unless domain_name.blank? or domain_name == "localhost" %>
95
+ server {
96
+ server_name <%= domain_name %>;
97
+ rewrite ^/(.*) http://www.<%= domain_name %>/$1 permanent;
98
+ }
99
+ <% end %>
@@ -23,14 +23,14 @@ source pages
23
23
 
24
24
  sql_query_pre = SET NAMES UTF8
25
25
  sql_query_pre = SET SESSION query_cache_type=OFF
26
- sql_query_pre = INSERT INTO indexer_status (id, started_at, status, index_name, hostname) VALUES (10, NOW(), 'indexing', 'pages', '<%= sphinx_hostname %>') \
26
+ sql_query_pre = INSERT INTO indexer_status (started_at, status, index_name, hostname) VALUES (NOW(), 'indexing', 'pages', USER()) \
27
27
  ON DUPLICATE KEY UPDATE started_at = NOW(), status = 'indexing'
28
28
 
29
29
  sql_query = SELECT id, user_id, language, UNIX_TIMESTAMP(created_at) AS created_at, UNIX_TIMESTAMP(updated_at) AS updated_at, body, title FROM pages WHERE id>=$start AND id<=$end
30
30
  sql_query_range = SELECT MIN(id),MAX(id) FROM pages where type='Article'
31
31
  sql_range_step = 1000
32
32
 
33
- sql_query_post = UPDATE indexer_status SET updated_at = NOW(), status = 'updated' WHERE index_name = 'pages' and hostname = '<%= sphinx_hostname %>'
33
+ sql_query_post = UPDATE indexer_status SET updated_at = NOW(), status = 'updated' WHERE index_name = 'pages' and hostname = USER()
34
34
 
35
35
  sql_attr_uint = user_id
36
36
  sql_attr_timestamp = created_at
@@ -43,15 +43,15 @@ source pages_delta : pages
43
43
  sql_query_pre =
44
44
  sql_query_pre = SET NAMES UTF8
45
45
  sql_query_pre = SET SESSION query_cache_type=OFF
46
- sql_query_pre = INSERT INTO indexer_status (id, started_at, status, index_name, hostname) VALUES (11, NOW(), 'indexing', 'pages_delta', '<%= sphinx_hostname %>') \
46
+ sql_query_pre = INSERT INTO indexer_status (id, started_at, status, index_name, hostname) VALUES (NOW(), 'indexing', 'pages_delta', USER()) \
47
47
  ON DUPLICATE KEY UPDATE started_at = NOW(), status = 'indexing'
48
48
 
49
49
  sql_query = SELECT id, user_id, language, UNIX_TIMESTAMP(created_at) AS created_at, UNIX_TIMESTAMP(updated_at) AS updated_at, body, title \
50
50
  FROM pages \
51
- WHERE updated_at >= (SELECT updated_at FROM indexer_status WHERE id = 11)
51
+ WHERE updated_at >= (SELECT updated_at FROM indexer_status WHERE index_name = 'pages_delta' and hostname = USER())
52
52
 
53
53
  sql_query_post =
54
- sql_query_post = UPDATE indexer_status SET updated_at = NOW(), status = 'updated' WHERE index_name = 'pages_delta' and hostname = '<%= sphinx_hostname %>'
54
+ sql_query_post = UPDATE indexer_status SET updated_at = NOW(), status = 'updated' WHERE index_name = 'pages_delta' and hostname = USER()
55
55
  sql_query_range =
56
56
  sql_range_step =
57
57
  }
data/website/index.html CHANGED
@@ -35,7 +35,7 @@
35
35
 
36
36
  <div id="version" class="clickable box" onclick='document.location = "http://rubyforge.org/projects/capitate"; return false'>
37
37
  <p>Get Version</p>
38
- <a href="http://rubyforge.org/projects/capitate" class="numbers">0.3.2</a>
38
+ <a href="http://rubyforge.org/projects/capitate" class="numbers">0.3.3</a>
39
39
  </div>
40
40
 
41
41
  <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.3.2
4
+ version: 0.3.3
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-04-03 00:00:00 -04:00
12
+ date: 2008-04-29 00:00:00 -04:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -63,12 +63,14 @@ files:
63
63
  - lib/capitate/task_node.rb
64
64
  - lib/capitate/version.rb
65
65
  - lib/deployment/centos-5.1-64-web/install.rb
66
+ - lib/recipes/active_record.rb
66
67
  - lib/recipes/backgroundrb.rb
67
68
  - lib/recipes/centos/backgroundjob.rb
68
69
  - lib/recipes/centos/backgroundrb.rb
69
70
  - lib/recipes/centos/centos.rb
70
71
  - lib/recipes/centos/imagemagick.rb
71
72
  - lib/recipes/centos/memcached.rb
73
+ - lib/recipes/centos/merb.rb
72
74
  - lib/recipes/centos/mongrel_cluster.rb
73
75
  - lib/recipes/centos/monit.rb
74
76
  - lib/recipes/centos/mysql.rb
@@ -78,6 +80,7 @@ files:
78
80
  - lib/recipes/docs.rb
79
81
  - lib/recipes/logrotate/backgroundjob.rb
80
82
  - lib/recipes/logrotate/backgroundrb.rb
83
+ - lib/recipes/logrotate/merb.rb
81
84
  - lib/recipes/logrotate/mongrel_cluster.rb
82
85
  - lib/recipes/logrotate/monit.rb
83
86
  - lib/recipes/logrotate/mysql.rb
@@ -91,6 +94,7 @@ files:
91
94
  - lib/recipes/monit/backgroundrb.rb
92
95
  - lib/recipes/monit/database.rb
93
96
  - lib/recipes/monit/memcached.rb
97
+ - lib/recipes/monit/merb.rb
94
98
  - lib/recipes/monit/mongrel_cluster.rb
95
99
  - lib/recipes/monit/mysql.rb
96
100
  - lib/recipes/monit/nginx.rb
@@ -112,6 +116,8 @@ files:
112
116
  - lib/templates/memcached/memcached.initd.centos.erb
113
117
  - lib/templates/memcached/memcached.monitrc.erb
114
118
  - lib/templates/memcached/memcached.yml.erb
119
+ - lib/templates/merb/merb.initd.centos.erb
120
+ - lib/templates/merb/merb.monitrc.erb
115
121
  - lib/templates/mongrel/mongrel_cluster.initd.centos.erb
116
122
  - lib/templates/mongrel/mongrel_cluster.monitrc.erb
117
123
  - lib/templates/mongrel/mongrel_cluster.yml.erb
@@ -126,6 +132,7 @@ files:
126
132
  - lib/templates/nginx/nginx.initd.centos.erb
127
133
  - lib/templates/nginx/nginx.monitrc.erb
128
134
  - lib/templates/nginx/nginx_vhost.conf.erb
135
+ - lib/templates/nginx/nginx_vhost_generic.conf.erb
129
136
  - lib/templates/rails/database.yml.erb
130
137
  - lib/templates/ruby/fix_openssl.sh
131
138
  - lib/templates/sphinx/sphinx.conf.erb