Permalink
Browse files

adding mysql recipes/templates, cleaning up docs

  • Loading branch information...
1 parent 03cbc3d commit d482ddbcaf346eac68e50ccd72370bb5fd3ac7de @gabriel committed Mar 27, 2008
View
22 Capfile
@@ -11,25 +11,3 @@ require 'lib/capitate/recipes'
require 'erb'
-# Test
-task :test_egrep do
- role :test, "10.0.6.118", :user => "root"
-
- found = utils.egrep("^mail.\\*", "/etc/syslog.conf")
- puts "Found? #{found}"
-
- found = utils.egrep("^fooo", "/etc/syslog.conf")
- puts "Found? #{found}"
-end
-
-task :test_app do
- set :application, "sick"
- set :deploy_to, "/var/www/apps/sick"
- role :web, "10.0.6.118", :user => "root"
- role :app, "10.0.6.118", :user => "root"
-end
-
-task :test_install do
- load File.dirname(__FILE__) + "/lib/deployment/centos-5.1-64-web/install.rb"
- role :test, "10.0.6.118", :user => "root"
-end
View
@@ -1,3 +1,10 @@
+== 0.2.14
+
+* Removing my lame monkey patches
+* Mysql cnf template
+* Cleaning up mysql grant locations
+* Logrotate for mysql slow query log
+
== 0.2.13 2008-03-26
* Fixing monit re/start for mongrel cluster and backgroundrb
View
@@ -10,7 +10,7 @@ config/requirements.rb
docs/nginx.README
lib/capitate.rb
lib/capitate/cap_ext/connections.rb
-lib/capitate/cap_ext/roles.rb
+lib/capitate/cap_ext/docs.rb
lib/capitate/cap_ext/run_via.rb
lib/capitate/cap_ext/variables.rb
lib/capitate/plugins/base.rb
@@ -41,13 +41,15 @@ lib/recipes/docs.rb
lib/recipes/logrotate/backgroundrb.rb
lib/recipes/logrotate/mongrel_cluster.rb
lib/recipes/logrotate/monit.rb
+lib/recipes/logrotate/mysql.rb
lib/recipes/logrotate/nginx.rb
lib/recipes/logrotate/rails.rb
lib/recipes/logrotate/sphinx.rb
lib/recipes/logrotated.rb
lib/recipes/memcached.rb
lib/recipes/monit.rb
lib/recipes/monit/backgroundrb.rb
+lib/recipes/monit/database.rb
lib/recipes/monit/memcached.rb
lib/recipes/monit/mongrel_cluster.rb
lib/recipes/monit/mysql.rb
@@ -75,6 +77,7 @@ lib/templates/monit/monit.cnf
lib/templates/monit/monit.initd.centos.erb
lib/templates/monit/monitrc.erb
lib/templates/mysql/install_db.sql.erb
+lib/templates/mysql/my.cnf.innodb_1024.erb
lib/templates/mysql/mysql.monitrc.erb
lib/templates/nginx/nginx.conf.erb
lib/templates/nginx/nginx.initd.erb
View
@@ -27,13 +27,13 @@ module Plugins # :nodoc:
require "capitate/cap_ext/connections"
require "capitate/cap_ext/variables"
require "capitate/cap_ext/run_via"
-require "capitate/cap_ext/roles"
+require "capitate/cap_ext/docs"
class Capistrano::Configuration
include Capitate::CapExt::Variables
include Capitate::CapExt::RunVia
- include Capitate::CapExt::Roles
include Capitate::CapExt::Connections
+ include Capitate::CapExt::Docs
end
#module Capistrano::Configuration::Connections; end
@@ -3,33 +3,6 @@ module Capitate
module CapExt
module Connections
- def self.included(base) #:nodoc:
- base.send :alias_method, :execute_on_servers_without_capitate, :execute_on_servers
- base.send :alias_method, :execute_on_servers, :execute_on_servers_with_capitate
- end
-
- # Determines the set of servers within the current task's scope and
- # establishes connections to them, and then yields that list of
- # servers.
- #
- # If you set:
- #
- # set :ignore_missing_roles, true
- #
- # Overriden to handle NoMatchingServersError as NON-FATAL.
- #
- def execute_on_servers_with_capitate(options={}, &block)
- if exists?(:ignore_missing_roles) && fetch(:ignore_missing_roles)
- begin
- execute_on_servers_without_capitate(options, &block)
- rescue Capistrano::NoMatchingServersError => e
- logger.important "`#{current_task.fully_qualified_name}' is only run for servers matching #{current_task.options.inspect}, but no servers matched"
- end
- else
- execute_on_servers_without_capitate(options, &block)
- end
- end
-
# Set the user to something new (but save the old user; reset_user will set it back).
# Takes care of invalidating current connections. Will force a re-login.
#
@@ -0,0 +1,26 @@
+module Capitate
+
+ module CapExt
+
+ module Docs
+
+ # Get link to github source, so we can refer to recipe code.
+ #
+ # ==== Options
+ # +recipe+:: Recipe path, probably use __FILE__
+ #
+ # ==== Examples
+ # # In a lib/recipes/foo/foo.rb
+ # link_to_source(__FILE__) => "http://github.com/gabriel/capitate/tree/master/lib/recipes/foo/foo.rb"
+ #
+ def link_to_source(recipe_path)
+ full_path = File.expand_path(recipe_path)
+ project_path = File.expand_path(File.dirname(__FILE__) + "/../../../")
+ "http://github.com/gabriel/capitate/tree/master#{full_path.sub(project_path, "")}"
+ end
+
+ end
+
+ end
+
+end
@@ -1,26 +0,0 @@
-module Capitate
- module CapExt
- module Roles
-
- def self.included(base) #:nodoc:
- base.send :alias_method, :role_list_from_without_capitate, :role_list_from
- base.send :alias_method, :role_list_from, :role_list_from_with_capitate
- end
-
- def role_list_from_with_capitate(roles)
- roles = roles.split(/,/) if String === roles
- roles = build_list(roles)
- roles.map { |role|
- role = String === role ? role.strip.to_sym : role
- unless self.roles.key?(role)
- logger.important "unknown role `#{role}'"
- nil
- else
- role
- end
- }.compact
- end
-
- end
- end
-end
@@ -125,13 +125,6 @@ def fetch_role(name, options = {})
nil
end
-
- def link_to_source(recipe_path)
- full_path = File.expand_path(recipe_path)
- project_path = File.expand_path(File.dirname(__FILE__) + "/../../../")
- "http://github.com/gabriel/capitate/tree/master#{full_path.sub(project_path, "")}"
- end
-
end
end
View
@@ -2,7 +2,7 @@ module Capitate #:nodoc:
module VERSION #:nodoc:
MAJOR = 0
MINOR = 2
- TINY = 13
+ TINY = 14
STRING = [MAJOR, MINOR, TINY].join('.')
end
@@ -10,6 +10,7 @@
<dd>Backgroundrb logrotate paths.</dd>
<dd class="default">Defaults to @\#{shared_path}/log/backgroundrb*.log@</dd>
</dl>
+ "Source":#{link_to_source(__FILE__)}
DESC
task :install do
fetch_or_default(:backgroundrb_logrotate_path, "#{shared_path}/log/backgroundrb*.log")
@@ -6,7 +6,12 @@
desc <<-DESC
Install logrotated conf for mongrel cluster.
- *mongrel_cluster_logrotate_path*: Mongrel cluster logrotate path. _Defaults to <tt>{shared_path}/log/mongrel_cluster_*.log</tt>_
+ <dl>
+ <dt>mongrel_cluster_logrotate_path</dt>
+ <dd>Mongrel cluster logrotate path</dd>
+ <dd class="default">Defaults to @\#{shared_path}/log/mongrel_cluster_*.log@</dd>
+ </dl>
+ "Source":#{link_to_source(__FILE__)}
DESC
task :install do
fetch_or_default(:mongrel_cluster_logrotate_path, "#{shared_path}/log/mongrel_cluster_*.log")
@@ -5,7 +5,12 @@
desc <<-DESC
Install logrotated conf for monit.
- *monit_log_path*: Path to monit log. _Defaults to <tt>/var/log/monit.log</tt>_
+ <dl>
+ <dt>monit_log_path</dt>
+ <dd>Path to monit log</dd>
+ <dd class="default">Defaults to @"/var/log/monit.log"@</dd>
+ </dl>
+ "Source":#{link_to_source(__FILE__)}
DESC
task :install do
@@ -0,0 +1,26 @@
+namespace :mysql do
+
+ namespace :logrotate do
+
+ desc <<-DESC
+ Install logrotated conf for nginx.
+
+ <dl>
+ <dt>mysql_logrotate_path</dt>
+ <dd>Mysql logrotate path</dd>
+ <dd class="default">Defaults to @"/var/lib/mysql/localhost-slow.log"@</dd>
+ </dl>
+ "Source":#{link_to_source(__FILE__)}
+ DESC
+ task :install, :roles => :db do
+ fetch_or_default(:mysql_logrotate_path, "/var/lib/mysql/localhost-slow.log")
+
+ set :logrotate_name, "mysql"
+ set :logrotate_log_path, mysql_logrotate_path
+ set :logrotate_options, [ { :rotate => 7, :size => "10M" }, :daily, :missingok, :notifempty, :copytruncate ]
+
+ logrotated.install_conf
+ end
+
+ end
+end
View
@@ -55,6 +55,17 @@
desc <<-DESC
Force rotate files.
+
+ <dl>
+ <dt>logrotate_prefix</dt>
+ <dd>Path to logrotate</dd>
+ <dd>Defaults to none</dd>
+
+ <dt>logrotate_conf_path</dt>
+ <dd>Path to logrotate conf</dd>
+ <dd>Defaults to @"/etc/logrotate.conf"@</dd>
+ </dl>
+ "Source":#{link_to_source(__FILE__)}
DESC
task :force do
View
@@ -1,6 +1,38 @@
namespace :memcached do
- desc "Create memcached yaml in shared path."
+ desc <<-DESC
+ Create memcached yaml in shared path.
+
+ <dl>
+ <dt>memcached_namespace</dt>
+
+ <dt>memcached_ttl</dt>
+ <dd class="default">Defaults to @3600@</dd>
+
+ <dt>memcached_readonly</dt>
+ <dd class="default">Defaults to @false@</dd>
+
+ <dt>memcached_urlencode</dt>
+ <dd class="default">Defaults to @false@</dd>
+
+ <dt>memcached_c_threshold</dt>
+ <dd class="default">Defaults to @10000@</dd>
+
+ <dt>memcached_compression</dt>
+ <dd class="default">Defaults to @true@</dd>
+
+ <dt>memcached_debug</dt>
+ <dd class="default">Defaults to @false@</dd>
+
+ <dt>memcached_servers</dt>
+ <dd class="default">Defaults to @[ "localhost:11211" ]@</dd>
+
+ <dt>memcached_yml_template</dt>
+ <dd class="default">Defaults to @"memcached/memcached.yml.erb"@</dd>
+ </dl>
+
+ "Source":#{link_to_source(__FILE__)}
+ DESC
task :setup do
# Settings
@@ -23,13 +23,13 @@
sudo "#{monit_bin_path} restart backgroundrb_#{application}"
end
- desc "Start mongrel cluster (for application)"
+ desc "Start backgroundrb (for application)"
task :start do
fetch_or_default(:monit_bin_path, "monit")
sudo "#{monit_bin_path} start backgroundrb_#{application}"
end
- desc "Stop mongrel cluster (for application)"
+ desc "Stop backgroundrb (for application)"
task :stop do
fetch_or_default(:monit_bin_path, "monit")
sudo "#{monit_bin_path} stop backgroundrb_#{application}"
@@ -0,0 +1,25 @@
+namespace :database do
+
+ namespace :monit do
+
+ desc "Restart database (monit group)"
+ task :restart do
+ fetch_or_default(:monit_bin_path, "monit")
+ sudo "#{monit_bin_path} -g database restart all"
+ end
+
+ desc "Start database (monit group)"
+ task :start do
+ fetch_or_default(:monit_bin_path, "monit")
+ sudo "#{monit_bin_path} -g database start all"
+ end
+
+ desc "Stop database (monit group)"
+ task :stop do
+ fetch_or_default(:monit_bin_path, "monit")
+ sudo "#{monit_bin_path} -g database stop all"
+ end
+
+ end
+
+end
Oops, something went wrong.

0 comments on commit d482ddb

Please sign in to comment.