capitate 0.2.15 → 0.3.1

Sign up to get free protection for your applications and to get access to all the features.
data/History.txt CHANGED
@@ -1,3 +1,9 @@
1
+ == 0.3.1 2008-04-02
2
+
3
+ * Fixing the init scripts to use killproc and have nice output (centos)
4
+ * Fixing sphinx initscript to clean on start (if process does not exist)
5
+ * Removing some roles options. Roles are confusing, I don't want to use them.
6
+
1
7
  == 0.2.15 2008-03-31
2
8
 
3
9
  * Adding backgroundjob recipes and templates.
data/Manifest.txt CHANGED
@@ -75,7 +75,7 @@ lib/templates/logrotated/conf.erb
75
75
  lib/templates/memcached/memcached.initd.centos.erb
76
76
  lib/templates/memcached/memcached.monitrc.erb
77
77
  lib/templates/memcached/memcached.yml.erb
78
- lib/templates/mongrel/mongrel_cluster.initd.erb
78
+ lib/templates/mongrel/mongrel_cluster.initd.centos.erb
79
79
  lib/templates/mongrel/mongrel_cluster.monitrc.erb
80
80
  lib/templates/mongrel/mongrel_cluster.yml.erb
81
81
  lib/templates/monit/monit.cnf
@@ -83,9 +83,10 @@ lib/templates/monit/monit.initd.centos.erb
83
83
  lib/templates/monit/monitrc.erb
84
84
  lib/templates/mysql/install_db.sql.erb
85
85
  lib/templates/mysql/my.cnf.innodb_1024.erb
86
+ lib/templates/mysql/my.cnf.innodb_512.erb
86
87
  lib/templates/mysql/mysql.monitrc.erb
87
88
  lib/templates/nginx/nginx.conf.erb
88
- lib/templates/nginx/nginx.initd.erb
89
+ lib/templates/nginx/nginx.initd.centos.erb
89
90
  lib/templates/nginx/nginx.monitrc.erb
90
91
  lib/templates/nginx/nginx_vhost.conf.erb
91
92
  lib/templates/rails/database.yml.erb
@@ -22,22 +22,23 @@ module Capitate::Plugins::Prompt
22
22
  # +verify+:: If true, prompt twice and verify
23
23
  # +lazy+:: If true, returns a Proc. _Defaults to true_
24
24
  # +check_hash+:: If present, checks that md5 is same as password md5
25
+ # +max_attempts+:: Number of attempts to retry. _Defaults to 3_
25
26
  #
26
27
  def password(label, options = {})
27
28
 
28
29
  verify = options[:verify]
29
30
  lazy = options[:lazy].nil? ? true : options[:lazy]
30
31
  check_hash = options[:check_hash]
32
+ max_attempts = options[:max_attempts] || 3
31
33
 
32
34
  # Lazy
33
35
  password_prompt = Proc.new {
34
36
 
35
- max_attempts = 2
36
37
  attempts = 0
37
38
  password = nil
38
39
  success = true
39
40
 
40
- loop {
41
+ loop do
41
42
  password = Capistrano::CLI.password_prompt(label)
42
43
  attempts += 1
43
44
 
@@ -52,13 +53,16 @@ module Capitate::Plugins::Prompt
52
53
  if check_hash
53
54
  if MD5.md5(password).hexdigest != check_hash
54
55
  logger.important "Invalid password, try again."
55
- success = false
56
+ success = false
56
57
  end
57
58
  end
58
59
 
59
60
  break if success
60
61
  break if attempts >= max_attempts
61
- }
62
+
63
+ # Reset success
64
+ success = true
65
+ end
62
66
 
63
67
  raise "Invalid password, too many tries" unless success
64
68
 
@@ -19,6 +19,24 @@ module Capitate::Plugins::Utils
19
19
  end
20
20
  end
21
21
 
22
+ # Delete file.
23
+ #
24
+ # ==== Options
25
+ # +path+:: Path to delete
26
+ #
27
+ def rm(path)
28
+ run_via "rm #{path}"
29
+ end
30
+
31
+ # Delete file (recursive/force)
32
+ #
33
+ # ==== Options
34
+ # +path+:: Path to delete
35
+ #
36
+ def rm_rf(path)
37
+ run_via "rm -rf #{path}"
38
+ end
39
+
22
40
  # Load template and install it.
23
41
  # Removes temporary files during transfer and ensures desination directory is created before install.
24
42
  #
@@ -169,7 +169,9 @@ class Capitate::TaskNode
169
169
  file.puts "\n\nh2. Task documentation\n\n"
170
170
  sorted_tasks.each do |task|
171
171
  file.puts %{<div class="recipe">\n\n}
172
- file.puts "h3(##{task.fully_qualified_name}). #{task.fully_qualified_name}\n\n"
172
+ options = ""
173
+ options = "<span class='options'>, #{task.options.inspect}</span>" unless task.options.blank?
174
+ file.puts "h3(##{task.fully_qualified_name}). #{task.fully_qualified_name}#{options}\n\n"
173
175
  file.puts "#{unindent(task.desc)}\n\n"
174
176
  file.puts "</div>\n\n\n"
175
177
  end
@@ -1,8 +1,8 @@
1
1
  module Capitate #:nodoc:
2
2
  module VERSION #:nodoc:
3
3
  MAJOR = 0
4
- MINOR = 2
5
- TINY = 15
4
+ MINOR = 3
5
+ TINY = 1
6
6
 
7
7
  STRING = [MAJOR, MINOR, TINY].join('.')
8
8
  end
@@ -25,9 +25,6 @@ namespace :backgroundjob do
25
25
  "Source":#{link_to_source(__FILE__)}
26
26
  DESC
27
27
  task :setup do
28
-
29
-
30
-
31
28
  # Settings
32
29
  fetch_or_default(:backgroundjob_pid_path, "#{shared_path}/pids/bj.pid")
33
30
  fetch_or_default(:backgroundjob_log_path, "#{shared_path}/log/bj.log")
@@ -48,11 +48,37 @@ namespace :memcached do
48
48
  # Build
49
49
  build.make_install("memcached", memcached_build_options)
50
50
 
51
- # Install initscript, service
52
- put template.load("memcached/memcached.initd.centos.erb"), "/tmp/memcached.initd"
53
- run_via "install -o root /tmp/memcached.initd /etc/init.d/memcached && rm -f /tmp/memcached.initd"
54
- run_via "/sbin/chkconfig --level 345 memcached on"
55
-
51
+ initscript
52
+ end
53
+
54
+ desc <<-DESC
55
+ Install memcached initscript.
56
+
57
+ <dl>
58
+ <dt>memcached_memory</dt>
59
+ <dd>Memcached memory (in MB).</dd>
60
+ <dd>@set :memcached_memory, 64@</dd>
61
+
62
+ <dt>memcached_pid_path*</dt>
63
+ <dd>Path to memcached pid file.</dd>
64
+ <dd class="default">Defaults to @/var/run/memcached.pid@</dd>
65
+ <dd>@set :memcached_pid_path, "/var/run/memcached.pid"@</dd>
66
+
67
+ <dt>memcached_port</dt>
68
+ <dd>Memcached port<dd>
69
+ <dd class="default">Defaults to 11211.</dd>
70
+ <dd>@set :memcached_port, 11211@</dd>
71
+ </dl>
72
+ "Source":#{link_to_source(__FILE__)}
73
+ DESC
74
+ task :initscript do
75
+
76
+ fetch_or_default(:memcached_pid_path, "/var/run/memcached.pid")
77
+ fetch_or_default(:memcached_port, 11211)
78
+ fetch(:memcached_memory)
79
+
80
+ utils.install_template("memcached/memcached.initd.centos.erb", "/etc/init.d/memcached")
81
+ run_via "/sbin/chkconfig --level 345 memcached on"
56
82
  end
57
83
 
58
84
  end
@@ -61,16 +61,24 @@ namespace :mongrel do
61
61
 
62
62
  set :mongrel_pid_path, "#{mongrel_pid_dir}/#{mongrel_application}.pid"
63
63
  set :mongrel_log_path, "log/#{mongrel_application}.log"
64
-
65
- put template.load("mongrel/mongrel_cluster.initd.erb"), "/tmp/#{mongrel_initscript_name}.initd"
64
+
66
65
  put template.load("mongrel/mongrel_cluster.yml.erb"), "#{mongrel_config_dir}/mongrel_cluster.yml"
67
66
 
68
- # Setup the mongrel_cluster init script
69
- sudo "install -o root /tmp/#{mongrel_initscript_name}.initd /etc/init.d/#{mongrel_initscript_name}"
67
+ initscript
68
+ end
69
+
70
+ desc "Mongrel cluster setup initscript for application"
71
+ task :initscript do
72
+
73
+ fetch_or_default(:mongrel_config_dir, "#{shared_path}/config/mongrel")
74
+ fetch_or_default(:mongrel_pid_dir, "#{shared_path}/pids")
75
+ fetch_or_default(:mongrel_cluster_command, "mongrel_cluster_ctl")
76
+ fetch_or_default(:mongrel_initscript_name, "mongrel_cluster_#{application}")
70
77
 
71
- sudo "/sbin/chkconfig --level 345 #{mongrel_initscript_name} on"
78
+ utils.install_template("mongrel/mongrel_cluster.initd.centos.erb", "/etc/init.d/#{mongrel_initscript_name}")
79
+ run_via "/sbin/chkconfig --level 345 #{mongrel_initscript_name} on"
72
80
  end
73
-
81
+
74
82
  end
75
83
 
76
84
  end
@@ -52,7 +52,7 @@ namespace :monit do
52
52
  yum.install([ "flex", "byacc" ])
53
53
 
54
54
  # Build
55
- #build.make_install("monit", monit_build_options)
55
+ build.make_install("monit", monit_build_options)
56
56
 
57
57
  # Install initscript
58
58
  utils.install_template("monit/monit.initd.centos.erb", "/etc/init.d/monit")
@@ -82,20 +82,7 @@ namespace :monit do
82
82
  # HUP the inittab
83
83
  run_via "telinit q"
84
84
  end
85
-
86
- desc <<-DESC
87
- Install monit firewall rule.
88
-
89
- *monit_port*: Monit port. _Defaults to 2812_\n
90
- @set :monit_port, 2812@\n
91
- DESC
92
- task :iptables do
93
- # Settings
94
- fetch_or_default(:monit_port, 2812)
95
- run_via "iptables -A RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp --dport #{monit_port} -j ACCEPT"
96
- run_via "/sbin/service iptables save"
97
- end
98
-
85
+
99
86
  end
100
87
 
101
88
  end
@@ -57,10 +57,8 @@ namespace :nginx do
57
57
  # Build
58
58
  build.make_install("nginx", nginx_build_options)
59
59
 
60
- # Install initscript, and turn it on
61
- put template.load("nginx/nginx.initd.erb"), "/tmp/nginx.initd"
62
- run_via "install -o root /tmp/nginx.initd /etc/init.d/nginx && rm -f /tmp/nginx.initd"
63
- run_via "/sbin/chkconfig --level 345 nginx on"
60
+ # Initscript
61
+ initscript
64
62
 
65
63
  # Setup nginx
66
64
  run_via "mkdir -p /etc/nginx/vhosts"
@@ -72,6 +70,16 @@ namespace :nginx do
72
70
  run_via "id nginx || /usr/sbin/adduser -r nginx"
73
71
  end
74
72
 
73
+ desc "Install nginx initscript"
74
+ task :initscript do
75
+ fetch_or_default(:nginx_bin_path, "/sbin/nginx")
76
+ fetch_or_default(:nginx_conf_path, "/etc/nginx/nginx.conf")
77
+ fetch_or_default(:nginx_pid_path, "/var/run/nginx.pid")
78
+
79
+ utils.install_template("nginx/nginx.initd.centos.erb", "/etc/init.d/nginx")
80
+ run_via "/sbin/chkconfig --level 345 nginx on"
81
+ end
82
+
75
83
  # Restart nginx
76
84
  desc "Restart nginx (service)"
77
85
  task :restart do
@@ -57,37 +57,26 @@ namespace :sphinx do
57
57
  fetch_or_default(:sphinx_conf_path, "#{shared_path}/config/sphinx.conf")
58
58
  fetch_or_default(:sphinx_index_root, "#{shared_path}/var/index")
59
59
 
60
- # Install initscript
61
- put template.load("sphinx/sphinx_app.initd.centos.erb"), "/tmp/sphinx.initd"
62
- run_via "install -o root /tmp/sphinx.initd /etc/init.d/sphinx_#{application}"
63
-
64
- # Enable service
65
- run_via "/sbin/chkconfig --level 345 sphinx_#{application} on"
60
+ initscript
66
61
 
67
62
  # Create app indexes dir
68
63
  run "mkdir -p #{shared_path}/var/index"
69
64
  end
70
65
 
71
66
 
72
- desc <<-DESC
73
- Install sphinx firewall rule.
74
-
75
- This doesn't work yet (doesn't insert in right place).
76
-
77
- <dl>
78
- <dt>sphinx_portdt>
79
- <dd>Sphinx port</dd>
80
- <dd class="default">Defaults to @3312@</dd>
81
- <dd>@set :sphinx_port, 3312@</dd>
82
- </dl>
83
- "Source":#{link_to_source(__FILE__)}
84
- DESC
85
- task :iptables do
86
- # Settings
87
- fetch_or_default(:sphinx_port, 3312)
88
- run_via "iptables -A RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp --dport #{sphinx_port} -j ACCEPT"
89
- run_via "/sbin/service iptables save"
67
+ desc "Setup sphinx initscript"
68
+ task :initscript do
69
+
70
+ fetch_or_default(:sphinx_prefix, "/usr/local/sphinx")
71
+ fetch_or_default(:sphinx_pid_path, "#{shared_path}/pids/searchd.pid")
72
+ fetch_or_default(:sphinx_conf_path, "#{shared_path}/config/sphinx.conf")
73
+ fetch_or_default(:sphinx_index_root, "#{shared_path}/var/index")
74
+
75
+ utils.install_template("sphinx/sphinx_app.initd.centos.erb", "/etc/init.d/sphinx_#{application}")
76
+ run_via "/sbin/chkconfig --level 345 sphinx_#{application} on"
77
+
90
78
  end
79
+
91
80
  end
92
81
 
93
82
  end
@@ -3,7 +3,7 @@ namespace :mysql do
3
3
  namespace :logrotate do
4
4
 
5
5
  desc <<-DESC
6
- Install logrotated conf for nginx.
6
+ Install logrotated conf for mysql.
7
7
 
8
8
  <dl>
9
9
  <dt>mysql_logrotate_path</dt>
@@ -12,7 +12,7 @@ namespace :mysql do
12
12
  </dl>
13
13
  "Source":#{link_to_source(__FILE__)}
14
14
  DESC
15
- task :install, :roles => :db do
15
+ task :install do
16
16
  fetch_or_default(:mysql_logrotate_path, "/var/lib/mysql/localhost-slow.log")
17
17
 
18
18
  set :logrotate_name, "mysql"
@@ -3,11 +3,11 @@ namespace :backgroundjob do
3
3
  namespace :monit do
4
4
 
5
5
  desc <<-DESC
6
- Generate and install backgroundjob (for application) monitrc.
6
+ Setup backgroundjob (for application) monitrc.
7
7
 
8
8
  "Source":#{link_to_source(__FILE__)}
9
9
  DESC
10
- task :install do
10
+ task :setup do
11
11
 
12
12
  # Settings
13
13
  fetch_or_default(:backgroundjob_pid_path, "#{shared_path}/pids/bj.pid")
@@ -20,7 +20,7 @@ namespace :mysql do
20
20
 
21
21
  "Source":#{link_to_source(__FILE__)}
22
22
  DESC
23
- task :install, :roles => :db do
23
+ task :install do
24
24
 
25
25
  # Settings
26
26
  fetch_or_default(:mysql_pid_path, "/var/run/mysqld/mysqld.pid")
data/lib/recipes/mysql.rb CHANGED
@@ -22,28 +22,34 @@ namespace :mysql do
22
22
  <dd>Grant privilege types.</dd>
23
23
  <dd>Defaults to @ALL@</dd>
24
24
 
25
+ <dt>mysql_admin_user</dt>
26
+ <dd>Mysql admin user.</dd>
27
+ <dd>Defaults to password prompt.</dd>
28
+
25
29
  <dt>mysql_admin_password</dt>
26
- <dd>Mysql admin password (to use to connect).</dd>
30
+ <dd>Mysql admin password.</dd>
27
31
  <dd>Defaults to password prompt.</dd>
28
32
  </dl>
29
33
  "Source":#{link_to_source(__FILE__)}
30
34
  DESC
31
- task :setup, :roles => :db do
35
+ task :setup do
32
36
 
33
37
  # Settings
34
38
  fetch(:db_name)
35
39
  fetch(:db_user)
36
40
  fetch(:db_pass)
41
+ fetch_or_default(:mysql_admin_user, "root")
37
42
  fetch_or_default(:mysql_admin_password, prompt.password('Mysql admin password: '))
38
43
  fetch_or_default(:mysql_grant_priv_type, "ALL")
39
44
  fetch_or_default(:mysql_grant_locations, [ "localhost" ])
40
45
 
41
46
  sql = template.load("mysql/install_db.sql.erb")
42
47
 
43
- logger.trace "Running sql:\n#{sql}"
48
+ logger.trace "Running sql:\n#{sql}\n"
44
49
 
45
- put sql, "/tmp/install_db_#{application}.sql"
46
- run "mysql -u root -p#{mysql_admin_password} < /tmp/install_db_#{application}.sql"
50
+ put sql, "/tmp/install_db_#{application}.sql"
51
+ run "mysql -u #{mysql_admin_user} -p#{mysql_admin_password} < /tmp/install_db_#{application}.sql"
52
+ utils.rm("/tmp/install_db_#{application}.sql")
47
53
  end
48
54
 
49
55
  desc <<-DESC
@@ -64,7 +70,7 @@ namespace :mysql do
64
70
 
65
71
  "Source":#{link_to_source(__FILE__)}
66
72
  DESC
67
- task :install_my_cnf, :roles => :db do
73
+ task :install_my_cnf do
68
74
  fetch_or_default(:my_cnf_template, "mysql/my.cnf.innodb_1024.erb")
69
75
  fetch_or_default(:db_socket, "/var/lib/mysql/mysql.sock")
70
76
  fetch_or_default(:db_port, 3306)
data/lib/recipes/rails.rb CHANGED
@@ -2,19 +2,34 @@
2
2
  namespace :rails do
3
3
 
4
4
  desc <<-DESC
5
- Create database yaml in shared path. Note: If both <tt>:db_host</tt> and <tt>:db_socket</tt> are used,
6
- db_socket wins.
5
+ Create database yaml in shared path. Note: If both @:db_host@ and @:db_socket@ are used, @db_socket@ wins.
7
6
 
8
- *db_name*: Database name (rails).\n
9
- @set :db_name, "app_db_name"@\n
10
- *db_user*: Database user (rails).\n
11
- @set :db_user, "app_db_user"@\n
12
- *db_pass*: Database password (rails).\n
13
- @set :db_pass, "the_password"@\n
14
- *db_host*: Database host (can be nil, if you are using socket). _Defaults to nil_\n
15
- *db_socket*: Database socket (can be nil, if you are using host). _Defaults to nil_\n
16
- @set :db_socket, "/var/lib/mysql/mysql.sock"@\n
17
- *database_yml_template*: Path to database yml erb template. _Defaults to <tt>rails/database.yml.erb</tt>_ (in this GEM)\n
7
+ <dl>
8
+ <dt>db_name</dt>
9
+ <dd>Database name (rails).</dd>
10
+ <dd>@set :db_name, "app_db_name"@</dd>
11
+
12
+ <dt>db_user</dt>
13
+ <dd>Database user (rails).</dd>
14
+ <dd>@set :db_user, "app_db_user"@</dd>
15
+
16
+ <dt>db_pass</dt>
17
+ <dd>Database password (rails).</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>
18
33
 
19
34
  "Source":#{link_to_source(__FILE__)}
20
35
  DESC
@@ -17,31 +17,30 @@ DAEMON="<%= backgroundjob_bin_path %>"
17
17
  PIDFILE="<%= backgroundjob_pid_path %>"
18
18
 
19
19
  start() {
20
- daemon --user <%= user %> --pidfile $PIDFILE $DAEMON
20
+ echo -n $"Starting $DESC: "
21
+ daemon --user sick --pidfile $PIDFILE $DAEMON
21
22
  RETVAL=$?
22
23
  echo
23
24
  return $RETVAL;
24
25
  }
25
26
 
26
27
  stop() {
27
- kill -TERM `cat $PIDFILE` || echo -n " not running"
28
+ echo -n $"Stopping $DESC:"
29
+ killproc -p $PIDFILE
30
+ RETVAL=$?
31
+ echo
32
+ return $RETVAL;
28
33
  }
29
34
 
30
35
  case "$1" in
31
36
  start)
32
- echo -n "Starting $DESC: $NAME"
33
37
  start
34
- RETVAL=$?;
35
38
  ;;
36
- stop)
37
- echo -n "Stopping $DESC: $NAME"
38
- stop
39
- RETVAL=$?;
39
+ stop)
40
+ stop
40
41
  ;;
41
42
  restart)
42
- echo -n "Restarting $DESC: $NAME"
43
43
  stop
44
- # Sleep after stop
45
44
  sleep 1
46
45
  start
47
46
  RETVAL=$?;
@@ -22,6 +22,7 @@ PORT=<%= memcached_port %>
22
22
  USER=root
23
23
 
24
24
  start() {
25
+ echo -n $"Starting $DESC: "
25
26
  daemon $DAEMON -d -m $MEM -p $PORT -u $USER -P $PIDFILE
26
27
  RETVAL=$?
27
28
  echo
@@ -29,40 +30,27 @@ start() {
29
30
  }
30
31
 
31
32
  stop() {
32
- kill -QUIT `cat $PIDFILE` || echo -n " not running"
33
- }
34
-
35
- reload() {
36
- kill -HUP `cat $PIDFILE` || echo -n " can't reload"
33
+ echo -n $"Stopping $DESC: "
34
+ killproc -p $PIDFILE memcached
35
+ RETVAL=$?
36
+ echo
37
+ return $RETVAL;
37
38
  }
38
39
 
39
40
  case "$1" in
40
41
  start)
41
- echo -n "Starting $DESC: $NAME"
42
42
  start
43
- RETVAL=$?;
44
43
  ;;
45
44
  stop)
46
- echo "Stopping $DESC: $NAME"
47
45
  stop
48
- RETVAL=$?;
49
46
  ;;
50
- reload)
51
- echo -n "Reloading $DESC configuration..."
52
- reload
53
- RETVAL=$?;
54
- echo "reloaded."
55
- ;;
56
47
  restart)
57
- echo -n "Restarting $DESC: $NAME"
58
48
  stop
59
- # Sleep after stop
60
49
  sleep 1
61
50
  start
62
- RETVAL=$?;
63
51
  ;;
64
52
  *)
65
- echo "Usage: $0 {start|stop|restart|force-reload}" >&2
53
+ echo "Usage: $0 {start|stop|restart}" >&2
66
54
  RETVAL=3;
67
55
  ;;
68
56
  esac
@@ -11,8 +11,12 @@
11
11
  # Modified by: Gabriel Handford http://ducktyper.com
12
12
  #
13
13
 
14
- set -e
14
+ # Source function library
15
+ . /etc/rc.d/init.d/functions
15
16
 
17
+ RETVAL=0
18
+
19
+ NAME="mongrel_cluster_<%= application %>"
16
20
  CONF_DIR=<%= mongrel_config_dir %>
17
21
  PID_DIR=<%= mongrel_pid_dir %>
18
22
  USER=<%= user %>
@@ -20,6 +24,40 @@ CMD=<%= mongrel_cluster_command %>
20
24
 
21
25
  RETVAL=0
22
26
 
27
+ start() {
28
+ echo -n $"Starting $NAME: "
29
+ $CMD start -c $CONF_DIR --clean >/dev/null
30
+ RETVAL=$?
31
+ [ "$RETVAL" -eq 0 ] && success $"$NAME start" || failure $"$NAME start"
32
+ echo
33
+ return $RETVAL;
34
+ }
35
+
36
+ stop() {
37
+ echo -n $"Stopping $NAME: "
38
+ $CMD stop -c $CONF_DIR >/dev/null
39
+ RETVAL=$?
40
+ [ "$RETVAL" -eq 0 ] && success $"$NAME shutdown" || failure $"$NAME shutdown"
41
+ echo
42
+ return $RETVAL;
43
+ }
44
+
45
+ restart() {
46
+ echo -n $"Restarting $NAME: "
47
+ $CMD restart -c $CONF_DIR >/dev/null
48
+ RETVAL=$?
49
+ [ "$RETVAL" -eq 0 ] && success $"$NAME restart" || failure $"$NAME restart"
50
+ echo
51
+ return $RETVAL;
52
+ }
53
+
54
+ status() {
55
+ $CMD status -c $CONF_DIR
56
+ RETVAL=$?
57
+ echo
58
+ return $RETVAL;
59
+ }
60
+
23
61
  fail() {
24
62
  echo "Failed to start: $1"
25
63
  exit 1
@@ -31,30 +69,25 @@ which $CMD >/dev/null || fail "$CMD not found"
31
69
  # Go no further if config directory is missing.
32
70
  [ -d "$CONF_DIR" ] || fail "$CONF_DIR not found"
33
71
 
72
+ # Go no further if config directory is missing.
73
+ [ -d "$PID_DIR" ] || fail "$PID_DIR not found"
74
+
34
75
  case "$1" in
35
76
  start)
36
- # Create pid directory
37
- mkdir -p $PID_DIR
38
- chown $USER:$USER $PID_DIR
39
-
40
- $CMD start -c $CONF_DIR --clean
41
- RETVAL=$?
77
+ start
42
78
  ;;
43
79
  stop)
44
- $CMD stop -c $CONF_DIR
45
- RETVAL=$?
80
+ stop
46
81
  ;;
47
82
  restart)
48
- $CMD restart -c $CONF_DIR
49
- RETVAL=$?
83
+ restart
50
84
  ;;
51
85
  status)
52
- $CMD status -c $CONF_DIR
53
- RETVAL=$?
86
+ status
54
87
  ;;
55
88
  *)
56
89
  echo "Usage: $0 {start|stop|restart|status}"
57
- exit 1
90
+ RETVAL=3;
58
91
  ;;
59
92
  esac
60
93
 
@@ -19,7 +19,9 @@ CONFFILE=/etc/monitrc
19
19
  LOGFILE=<%= monit_log_path %>
20
20
  PIDFILE=<%= monit_pid_path %>
21
21
 
22
+
22
23
  start() {
24
+ echo -n $"Starting $DESC: "
23
25
  daemon $DAEMON -l $LOGFILE -p $PIDFILE -c $CONFFILE
24
26
  RETVAL=$?
25
27
  echo
@@ -27,40 +29,38 @@ start() {
27
29
  }
28
30
 
29
31
  stop() {
30
- kill -QUIT `cat $PIDFILE` || echo -n " not running"
32
+ echo -n $"Stopping $DESC: "
33
+ killproc -p $PIDFILE monit -TERM
34
+ RETVAL=$?
35
+ echo
36
+ return $RETVAL;
31
37
  }
32
38
 
33
39
  reload() {
34
- kill -HUP `cat $PIDFILE` || echo -n " can't reload"
40
+ echo -n $"Reloading $DESC: "
41
+ killproc -p $PIDFILE monit -HUP
42
+ RETVAL=$?
43
+ echo
44
+ return $RETVAL;
35
45
  }
36
46
 
37
47
  case "$1" in
38
48
  start)
39
- #echo -n "Starting $DESC: $NAME"
40
49
  start
41
- RETVAL=$?;
42
50
  ;;
43
51
  stop)
44
- echo "Stopping $DESC: $NAME"
45
52
  stop
46
- RETVAL=$?;
47
53
  ;;
48
54
  reload)
49
- echo -n "Reloading $DESC configuration..."
50
55
  reload
51
- RETVAL=$?;
52
- echo "reloaded."
53
56
  ;;
54
57
  restart)
55
- echo -n "Restarting $DESC: $NAME"
56
58
  stop
57
- # Sleep after stop
58
59
  sleep 1
59
60
  start
60
- RETVAL=$?;
61
61
  ;;
62
62
  *)
63
- echo "Usage: $0 {start|stop|restart|force-reload}" >&2
63
+ echo "Usage: $0 {start|stop|restart|reload}" >&2
64
64
  RETVAL=3;
65
65
  ;;
66
66
  esac
@@ -16,6 +16,8 @@
16
16
  # Licensed under the Academic Free License v. 3.0
17
17
  # http://blog.evanweaver.com/files/mysql/LICENSE
18
18
  #
19
+ # Modified by: gabrielh@gmail.com (http://ducktyper.com)
20
+ #
19
21
 
20
22
  [client]
21
23
  port = <%= db_port %>
@@ -99,7 +101,7 @@ log_long_format
99
101
 
100
102
  [mysqldump]
101
103
  quick
102
- max_allowed_packet = 16M
104
+ max_allowed_packet = 32M
103
105
 
104
106
  [mysql]
105
107
  no-auto-rehash
@@ -0,0 +1,127 @@
1
+ #
2
+ # my.cnf.innodb_1024
3
+ #
4
+ # This is a MySQL 5.x configuration file designed for the typical
5
+ # webapp, running on a 1GB server that is also the app and
6
+ # httpd server. The below configuration dedicates about half of
7
+ # the system resources to MySQL. It is InnoDB-specific, and
8
+ # will not perform well with many MyISAM tables. It supports
9
+ # limited ACID and referential integrity. It does not support
10
+ # replication.
11
+ #
12
+ # By Evan Weaver
13
+ # http://blog.evanweaver.com/articles/2007/04/30/top-secret-tuned-mysql-configurations-for-rails
14
+ #
15
+ # Copyright 2007, Cloudburst, LLC
16
+ # Licensed under the Academic Free License v. 3.0
17
+ # http://blog.evanweaver.com/files/mysql/LICENSE
18
+ #
19
+ # Modified by: gabrielh@gmail.com (http://ducktyper.com)
20
+ #
21
+
22
+ [client]
23
+ port = <%= db_port %>
24
+ socket = <%= db_socket %>
25
+ #max_allowed_packet = 32M
26
+
27
+ [mysqld]
28
+ ######### engine and access interfaces
29
+ skip-networking
30
+ skip-locking
31
+ skip-bdb
32
+
33
+ port = <%= db_port %>
34
+ socket = <%= db_socket %>
35
+ default-storage-engine = innodb
36
+
37
+ ######### character sets
38
+ character_set_server = utf8
39
+ collation_server = utf8_general_ci
40
+
41
+ ######### innodb options
42
+ innodb_additional_mem_pool_size = 16M
43
+ # buffer pool size is most critical for innodb's performance and memory usage
44
+ innodb_buffer_pool_size = 160M
45
+ # innodb_buffer_pool_size = 256M
46
+ innodb_data_file_path = ibdata1:10M:autoextend
47
+ innodb_data_home_dir = /var/lib/mysql
48
+ innodb_file_io_threads = 4
49
+ innodb_thread_concurrency = 4
50
+ # 2 is fastest but slightly less reliable than 0 or 1, if you don't trust your hard disks
51
+ innodb_flush_log_at_trx_commit = 2
52
+
53
+ innodb_log_buffer_size = 64M
54
+ # innodb_log_file_size * innodb_log_files_in_group < buffer_pool_size
55
+ innodb_log_file_size = 48M
56
+ # innodb_log_file_size = 80M
57
+ innodb_log_files_in_group = 3
58
+ # use a secondary volume if possible for a concurrent read/write speed boost
59
+ innodb_log_group_home_dir = /var/lib/mysql
60
+
61
+ innodb_max_dirty_pages_pct = 90
62
+ innodb_lock_wait_timeout = 120
63
+
64
+ ######### myisam
65
+ # innodb still requires the myisam engine for mysql's internal metadata table
66
+ key_buffer_size = 16M
67
+
68
+ ######### general
69
+ connect_timeout = 10
70
+ back_log = 50
71
+ # you can't have more mongrels or fastcgi processes than the max_connections setting
72
+ max_connections = 64
73
+ # max_connections = 96
74
+ max_connect_errors = 10
75
+ table_cache = 2048
76
+ max_allowed_packet = 32M
77
+
78
+ open_files_limit = 1024
79
+ # this is the in-memory tmp table max size
80
+ max_heap_table_size = 32M
81
+ # max_heap_table_size = 64M
82
+ # below are per-connection and per-sub-query
83
+ join_buffer_size = 4M
84
+ read_buffer_size = 4M
85
+ sort_buffer_size = 8M
86
+ read_rnd_buffer_size = 8M
87
+
88
+ thread_cache_size = 8
89
+ thread_concurrency = 8
90
+
91
+ # query_cache_size is a global setting
92
+ query_cache_size = 64M
93
+ # query_cache_size = 128M
94
+ query_cache_limit = 2M
95
+ thread_stack = 192K
96
+ transaction_isolation = READ-COMMITTED
97
+ # this is the on-disk max size
98
+ tmp_table_size = 128M
99
+ tmpdir = /tmp
100
+
101
+
102
+ # You can log slow queries to the mysql log directory to help isolate performance problems
103
+ log_slow_queries
104
+ long_query_time = 3
105
+ log_long_format
106
+
107
+ [mysqldump]
108
+ quick
109
+ max_allowed_packet = 32M
110
+
111
+ [mysql]
112
+ no-auto-rehash
113
+
114
+ [myisamchk]
115
+ # not used except when repairing the database at startup
116
+ key_buffer = 64M
117
+ sort_buffer_size = 64M
118
+ read_buffer = 2M
119
+ write_buffer = 2M
120
+
121
+ [mysqlhotcopy]
122
+ interactive-timeout
123
+
124
+ [mysqld_safe]
125
+ open-files-limit = 8192
126
+
127
+ # PS. Do not under any circumstances enable binlog
@@ -8,7 +8,8 @@
8
8
  # Modified: Geoffrey Grosenbach http://topfunky.com
9
9
  # Modified: Gabriel Handford http://ducktyper.com
10
10
 
11
- set -e
11
+ # Source function library
12
+ . /etc/rc.d/init.d/functions
12
13
 
13
14
  PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
14
15
  DESC="nginx daemon"
@@ -21,35 +22,41 @@ PIDFILE=<%= nginx_pid_path %>
21
22
  test -x $DAEMON || exit 0
22
23
 
23
24
  start() {
24
- $DAEMON -c $CONFIGFILE || echo -n " already running"
25
+ echo -n $"Starting $DESC: "
26
+ daemon $DAEMON -c $CONFIGFILE
27
+ RETVAL=$?
28
+ echo
29
+ return $RETVAL;
25
30
  }
26
31
 
27
32
  stop() {
28
- kill -QUIT `cat $PIDFILE` || echo -n " not running"
33
+ echo -n $"Stopping $DESC: "
34
+ killproc -p $PIDFILE nginx -QUIT
35
+ RETVAL=$?
36
+ echo
37
+ return $RETVAL;
29
38
  }
30
39
 
31
40
  reload() {
32
- kill -HUP `cat $PIDFILE` || echo -n " can't reload"
41
+ echo -n $"Reloading $DESC: "
42
+ killproc -p $PIDFILE nginx -HUP
43
+ RETVAL=$?
44
+ echo
45
+ return $RETVAL;
33
46
  }
34
47
 
35
48
  case "$1" in
36
49
  start)
37
- echo -n "Starting $DESC: $NAME"
38
50
  start
39
51
  ;;
40
52
  stop)
41
- echo -n "Stopping $DESC: $NAME"
42
53
  stop
43
54
  ;;
44
55
  reload)
45
- echo -n "Reloading $DESC configuration..."
46
56
  reload
47
- echo "reloaded."
48
57
  ;;
49
58
  restart)
50
- echo -n "Restarting $DESC: $NAME"
51
59
  stop
52
- # Sleep before start
53
60
  sleep 1
54
61
  start
55
62
  ;;
@@ -59,4 +66,4 @@ case "$1" in
59
66
  ;;
60
67
  esac
61
68
 
62
- exit 0
69
+ exit $RETVAL;
@@ -18,58 +18,63 @@ DAEMON=<%= sphinx_prefix %>/bin/searchd
18
18
  CONFIGFILE=<%= sphinx_conf_path %>
19
19
  PIDFILE=<%= sphinx_pid_path %>
20
20
  INDEX_DIR=<%= sphinx_index_root %>
21
+ USER=<%= user %>
22
+
21
23
 
22
24
  start() {
23
- daemon --user <%= user %> $DAEMON --config $CONFIGFILE
25
+ echo -n $"Starting $DESC: "
26
+ daemon --user $USER --pidfile $PIDFILE $DAEMON --config $CONFIGFILE
24
27
  RETVAL=$?
25
28
  echo
26
29
  return $RETVAL;
27
30
  }
28
31
 
29
32
  stop() {
30
- kill -QUIT `cat $PIDFILE` || echo -n " not running"
33
+ echo -n $"Stopping $DESC: "
34
+ killproc -p $PIDFILE
35
+ RETVAL=$?
36
+ echo
37
+ return $RETVAL;
31
38
  }
32
39
 
33
40
  reload() {
34
- kill -HUP `cat $PIDFILE` || echo -n " can't reload"
41
+ echo -n $"Reloading $DESC: "
42
+ killproc -p $PIDFILE searchd -HUP
43
+ RETVAL=$?
44
+ echo
45
+ return $RETVAL;
35
46
  }
36
47
 
37
48
  clean() {
38
- pid=`cat $PIDFILE`
49
+ echo -n $"Cleaning $DESC: "
50
+ pid=`cat $PIDFILE 2>/dev/null`
39
51
 
40
52
  if checkpid $pid; then
41
- echo -n " can't clean; running"
53
+ failure $"$NAME clean"
42
54
  else
43
55
  rm -f $INDEX_DIR/*.spl
44
- return $?
56
+ RETVAL=$?
57
+ [ "$RETVAL" -eq 0 ] && success $"$NAME clean" || failure $"$NAME clean"
45
58
  fi
46
- return 1
59
+ echo
60
+ return $RETVAL;
47
61
  }
48
62
 
49
63
  case "$1" in
50
64
  start)
51
- echo -n "Starting $DESC: $NAME"
65
+ clean
52
66
  start
53
- RETVAL=$?;
54
67
  ;;
55
68
  stop)
56
- echo -n "Stopping $DESC: $NAME"
57
69
  stop
58
- RETVAL=$?;
59
70
  ;;
60
71
  reload)
61
- echo -n "Reloading $DESC configuration..."
62
72
  reload
63
- RETVAL=$?;
64
- echo "reloaded."
65
73
  ;;
66
74
  restart)
67
- echo -n "Restarting $DESC: $NAME"
68
75
  stop
69
- # Sleep after stop
70
76
  sleep 1
71
77
  start
72
- RETVAL=$?;
73
78
  ;;
74
79
  clean)
75
80
  echo -n "Cleaning $DESC"
@@ -77,7 +82,7 @@ case "$1" in
77
82
  RETVAL=$?;
78
83
  ;;
79
84
  *)
80
- echo "Usage: $0 {start|stop|restart|force-reload}" >&2
85
+ echo "Usage: $0 {start|stop|restart|reload|clean}" >&2
81
86
  RETVAL=3;
82
87
  ;;
83
88
  esac
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.2.15</a>
38
+ <a href="http://rubyforge.org/projects/capitate" class="numbers">0.3.1</a>
39
39
  </div>
40
40
 
41
41
  <div id="recipes">
@@ -165,6 +165,10 @@ h2+ul {
165
165
  cursor: hand;
166
166
  }
167
167
 
168
+ .options {
169
+ font-size: 0.8em;
170
+ }
171
+
168
172
  /* Code highlighter */
169
173
  pre, code {
170
174
  font-family: "Bitstream Vera Sans Mono", monospace;
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.15
4
+ version: 0.3.1
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-03-31 00:00:00 -04:00
12
+ date: 2008-04-02 00:00:00 -04:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -112,7 +112,7 @@ files:
112
112
  - lib/templates/memcached/memcached.initd.centos.erb
113
113
  - lib/templates/memcached/memcached.monitrc.erb
114
114
  - lib/templates/memcached/memcached.yml.erb
115
- - lib/templates/mongrel/mongrel_cluster.initd.erb
115
+ - lib/templates/mongrel/mongrel_cluster.initd.centos.erb
116
116
  - lib/templates/mongrel/mongrel_cluster.monitrc.erb
117
117
  - lib/templates/mongrel/mongrel_cluster.yml.erb
118
118
  - lib/templates/monit/monit.cnf
@@ -120,9 +120,10 @@ files:
120
120
  - lib/templates/monit/monitrc.erb
121
121
  - lib/templates/mysql/install_db.sql.erb
122
122
  - lib/templates/mysql/my.cnf.innodb_1024.erb
123
+ - lib/templates/mysql/my.cnf.innodb_512.erb
123
124
  - lib/templates/mysql/mysql.monitrc.erb
124
125
  - lib/templates/nginx/nginx.conf.erb
125
- - lib/templates/nginx/nginx.initd.erb
126
+ - lib/templates/nginx/nginx.initd.centos.erb
126
127
  - lib/templates/nginx/nginx.monitrc.erb
127
128
  - lib/templates/nginx/nginx_vhost.conf.erb
128
129
  - lib/templates/rails/database.yml.erb