calas-capitate 0.3.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/Capfile +13 -0
- data/History.txt +167 -0
- data/License.txt +20 -0
- data/Manifest.txt +121 -0
- data/README.txt +8 -0
- data/Rakefile +4 -0
- data/config/hoe.rb +72 -0
- data/config/requirements.rb +17 -0
- data/lib/capitate.rb +56 -0
- data/lib/capitate/cap_ext/connections.rb +105 -0
- data/lib/capitate/cap_ext/docs.rb +26 -0
- data/lib/capitate/cap_ext/namespace.rb +34 -0
- data/lib/capitate/cap_ext/run_via.rb +16 -0
- data/lib/capitate/cap_ext/task_definition.rb +22 -0
- data/lib/capitate/cap_ext/variables.rb +132 -0
- data/lib/capitate/plugins/base.rb +140 -0
- data/lib/capitate/plugins/build.rb +71 -0
- data/lib/capitate/plugins/gem.rb +24 -0
- data/lib/capitate/plugins/prompt.rb +109 -0
- data/lib/capitate/plugins/rake.rb +25 -0
- data/lib/capitate/plugins/script.rb +96 -0
- data/lib/capitate/plugins/templates.rb +113 -0
- data/lib/capitate/plugins/utils.rb +151 -0
- data/lib/capitate/plugins/yum.rb +76 -0
- data/lib/capitate/recipes.rb +5 -0
- data/lib/capitate/task_node.rb +262 -0
- data/lib/capitate/version.rb +9 -0
- data/lib/deployment/centos-5.1-64-web/install.rb +196 -0
- data/lib/recipes/active_record.rb +36 -0
- data/lib/recipes/apache.rb +47 -0
- data/lib/recipes/backgroundrb.rb +29 -0
- data/lib/recipes/centos/backgroundjob.rb +27 -0
- data/lib/recipes/centos/backgroundrb.rb +23 -0
- data/lib/recipes/centos/centos.rb +45 -0
- data/lib/recipes/centos/imagemagick.rb +29 -0
- data/lib/recipes/centos/memcached.rb +45 -0
- data/lib/recipes/centos/merb.rb +23 -0
- data/lib/recipes/centos/mongrel_cluster.rb +54 -0
- data/lib/recipes/centos/monit.rb +62 -0
- data/lib/recipes/centos/mysql.rb +25 -0
- data/lib/recipes/centos/nginx.rb +64 -0
- data/lib/recipes/centos/ruby.rb +40 -0
- data/lib/recipes/centos/sphinx.rb +59 -0
- data/lib/recipes/docs.rb +24 -0
- data/lib/recipes/logrotate/backgroundjob.rb +26 -0
- data/lib/recipes/logrotate/backgroundrb.rb +26 -0
- data/lib/recipes/logrotate/merb.rb +25 -0
- data/lib/recipes/logrotate/mongrel_cluster.rb +29 -0
- data/lib/recipes/logrotate/monit.rb +28 -0
- data/lib/recipes/logrotate/mysql.rb +26 -0
- data/lib/recipes/logrotate/nginx.rb +37 -0
- data/lib/recipes/logrotate/rails.rb +21 -0
- data/lib/recipes/logrotate/sphinx.rb +21 -0
- data/lib/recipes/logrotated.rb +61 -0
- data/lib/recipes/memcached.rb +26 -0
- data/lib/recipes/merb.rb +32 -0
- data/lib/recipes/monit.rb +35 -0
- data/lib/recipes/monit/backgroundjob.rb +38 -0
- data/lib/recipes/monit/backgroundrb.rb +38 -0
- data/lib/recipes/monit/database.rb +25 -0
- data/lib/recipes/monit/memcached.rb +22 -0
- data/lib/recipes/monit/merb.rb +58 -0
- data/lib/recipes/monit/mongrel_cluster.rb +85 -0
- data/lib/recipes/monit/mysql.rb +20 -0
- data/lib/recipes/monit/nginx.rb +37 -0
- data/lib/recipes/monit/sphinx.rb +38 -0
- data/lib/recipes/monit/sshd.rb +27 -0
- data/lib/recipes/mysql.rb +42 -0
- data/lib/recipes/nginx.rb +29 -0
- data/lib/recipes/rails.rb +71 -0
- data/lib/recipes/redmine.rb +38 -0
- data/lib/recipes/sphinx.rb +60 -0
- data/lib/recipes/sshd.rb +47 -0
- data/lib/recipes/syslogd.rb +21 -0
- data/lib/templates/apache/vhost.mongrel_cluster.conf.erb +46 -0
- data/lib/templates/backgroundjob/backgroundjob.initd.centos.erb +54 -0
- data/lib/templates/backgroundjob/backgroundjob.monitrc.erb +3 -0
- data/lib/templates/backgroundrb/backgroundrb.initd.centos.erb +58 -0
- data/lib/templates/backgroundrb/backgroundrb.monitrc.erb +3 -0
- data/lib/templates/backgroundrb/backgroundrb.yml.erb +14 -0
- data/lib/templates/capistrano/Capfile +22 -0
- data/lib/templates/logrotated/conf.erb +3 -0
- data/lib/templates/memcached/memcached.initd.centos.erb +58 -0
- data/lib/templates/memcached/memcached.monitrc.erb +4 -0
- data/lib/templates/memcached/memcached.yml.erb +14 -0
- data/lib/templates/merb/merb-no-http.monitrc.erb +13 -0
- data/lib/templates/merb/merb.initd.centos.erb +123 -0
- data/lib/templates/merb/merb.monitrc.erb +15 -0
- data/lib/templates/mongrel/mongrel_cluster.initd.centos.erb +94 -0
- data/lib/templates/mongrel/mongrel_cluster.monitrc.erb +15 -0
- data/lib/templates/mongrel/mongrel_cluster.yml.erb +11 -0
- data/lib/templates/monit/monit.cnf +34 -0
- data/lib/templates/monit/monit.initd.centos.erb +68 -0
- data/lib/templates/monit/monitrc.erb +18 -0
- data/lib/templates/mysql/install_db.sql.erb +6 -0
- data/lib/templates/mysql/my.cnf.innodb_1024.erb +122 -0
- data/lib/templates/mysql/my.cnf.innodb_512.erb +127 -0
- data/lib/templates/mysql/mysql.monitrc.erb +6 -0
- data/lib/templates/nginx/nginx.conf.erb +97 -0
- data/lib/templates/nginx/nginx.initd.centos.erb +69 -0
- data/lib/templates/nginx/nginx.monitrc.erb +4 -0
- data/lib/templates/nginx/nginx_vhost.conf.erb +101 -0
- data/lib/templates/nginx/nginx_vhost_generic.conf.erb +99 -0
- data/lib/templates/rails/database.yml.erb +7 -0
- data/lib/templates/redmine/email.yml.erb +10 -0
- data/lib/templates/ruby/fix_openssl.sh +12 -0
- data/lib/templates/sphinx/sphinx.conf.erb +157 -0
- data/lib/templates/sphinx/sphinx.monitrc.erb +4 -0
- data/lib/templates/sphinx/sphinx_app.initd.centos.erb +90 -0
- data/lib/templates/sshd/sshd.monitrc.erb +5 -0
- data/script/destroy +14 -0
- data/script/generate +14 -0
- data/script/txt2html +80 -0
- data/setup.rb +1585 -0
- data/tasks/deployment.rake +34 -0
- data/tasks/environment.rake +7 -0
- data/tasks/website.rake +23 -0
- data/test/test_helper.rb +2 -0
- data/test/test_plugin_upload.rb +32 -0
- data/test/test_recipes.rb +37 -0
- data/test/test_templates.rb +29 -0
- metadata +198 -0
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
namespace :memcached do
|
|
2
|
+
|
|
3
|
+
desc <<-DESC
|
|
4
|
+
Create memcached yaml in shared path.
|
|
5
|
+
|
|
6
|
+
"Source":#{link_to_source(__FILE__)}
|
|
7
|
+
DESC
|
|
8
|
+
task_arg(:memcached_namespace, "Namespace")
|
|
9
|
+
task_arg(:memcached_ttl, "TTL in seconds", :default => 3600)
|
|
10
|
+
task_arg(:memcached_readonly, "Read only enabled", :default => false)
|
|
11
|
+
task_arg(:memcached_urlencode, "URL encode enabled", :default => false)
|
|
12
|
+
task_arg(:memcached_c_threshold, "C Threshold", :default => 10000)
|
|
13
|
+
task_arg(:memcached_compression, "Compression enabed", :default => true)
|
|
14
|
+
task_arg(:memcached_debug, "Debug enabled", :default => false)
|
|
15
|
+
task_arg(:memcached_servers, "List of servers", :default => ["localhost:11211"], :default_desc => "[\"localhost:11211\"]")
|
|
16
|
+
task_arg(:memcached_yml_template, "Memcached yml template", :default => "memcached/memcached.yml.erb")
|
|
17
|
+
task :setup do
|
|
18
|
+
put(memcached_yml_template, "#{shared_path}/config/memcached.yml")
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
desc "Symlink memcached configuration after deploy."
|
|
22
|
+
task :update_code, :roles => :app do
|
|
23
|
+
run "ln -nfs #{shared_path}/config/memcached.yml #{release_path}/config/memcached.yml"
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
end
|
data/lib/recipes/merb.rb
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
namespace :merb do
|
|
2
|
+
|
|
3
|
+
desc <<-DESC
|
|
4
|
+
Run the migrate rake task. By default, it runs this in most recently \
|
|
5
|
+
deployed version of the app. However, you can specify a different release \
|
|
6
|
+
via the migrate_target variable, which must be one of :latest (for the \
|
|
7
|
+
default behavior), or :current (for the release indicated by the \
|
|
8
|
+
`current' symlink). Strings will work for those values instead of symbols, \
|
|
9
|
+
too. You can also specify additional environment variables to pass to rake \
|
|
10
|
+
via the migrate_env variable. Finally, you can specify the full path to the \
|
|
11
|
+
rake executable by setting the rake variable. The defaults are:
|
|
12
|
+
|
|
13
|
+
set :rake, "rake"
|
|
14
|
+
set :merb_env, "production"
|
|
15
|
+
set :migrate_env, ""
|
|
16
|
+
set :migrate_target, :latest
|
|
17
|
+
DESC
|
|
18
|
+
task_arg(:rake, "Path to rake", :default => "rake")
|
|
19
|
+
task_arg(:merb_env, "Merb environment", :default => "")
|
|
20
|
+
task_arg(:migrate_target, "Migration target", :default => :latest)
|
|
21
|
+
task :migrate, :roles => :db, :only => { :primary => true } do
|
|
22
|
+
|
|
23
|
+
current_directory = case migrate_target.to_sym
|
|
24
|
+
when :current then current_path
|
|
25
|
+
when :latest then current_release
|
|
26
|
+
else raise ArgumentError, "unknown migration target #{migrate_target.inspect}"
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
run "cd #{current_directory}; #{rake} MERB_ENV=#{merb_env} #{migrate_env} db:migrate"
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
end
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
namespace :monit do
|
|
2
|
+
|
|
3
|
+
desc <<-DESC
|
|
4
|
+
Restart (HUP) monit process.
|
|
5
|
+
|
|
6
|
+
HUP's the process from the pid file, if it exists.
|
|
7
|
+
|
|
8
|
+
"Source":#{link_to_source(__FILE__)}
|
|
9
|
+
DESC
|
|
10
|
+
task_arg(:monit_pid_path, "Path to monit pid file", :default => "/var/run/monit.pid")
|
|
11
|
+
task :restart do
|
|
12
|
+
run_via %{sh -c "[ ! -e '#{monit_pid_path}' ] || kill -HUP `cat #{monit_pid_path}`"}
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
desc <<-DESC
|
|
16
|
+
Unmonitor all.
|
|
17
|
+
|
|
18
|
+
"Source":#{link_to_source(__FILE__)}
|
|
19
|
+
DESC
|
|
20
|
+
task_arg(:monit_bin_path, "Path to monit bin.", :default => "monit")
|
|
21
|
+
task :unmonitor_all do
|
|
22
|
+
run_via "#{monit_bin_path} unmonitor all"
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
desc <<-DESC
|
|
26
|
+
Monitor all.
|
|
27
|
+
|
|
28
|
+
"Source":#{link_to_source(__FILE__)}
|
|
29
|
+
DESC
|
|
30
|
+
task_arg(:monit_bin_path, "Path to monit bin.", :default => "monit")
|
|
31
|
+
task :monitor_all do
|
|
32
|
+
run_via "#{monit_bin_path} monitor all"
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
end
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
namespace :backgroundjob do
|
|
2
|
+
|
|
3
|
+
namespace :monit do
|
|
4
|
+
|
|
5
|
+
desc <<-DESC
|
|
6
|
+
Setup backgroundjob (for application) monitrc.
|
|
7
|
+
|
|
8
|
+
"Source":#{link_to_source(__FILE__)}
|
|
9
|
+
DESC
|
|
10
|
+
task :setup do
|
|
11
|
+
|
|
12
|
+
# Settings
|
|
13
|
+
fetch_or_default(:backgroundjob_pid_path, "#{shared_path}/pids/bj.pid")
|
|
14
|
+
fetch_or_default(:monit_conf_dir, "/etc/monit")
|
|
15
|
+
|
|
16
|
+
utils.install_template("backgroundjob/backgroundjob.monitrc.erb", "#{monit_conf_dir}/backgroundjob.monitrc")
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
desc "Restart backgroundrb (for application)"
|
|
20
|
+
task :restart do
|
|
21
|
+
fetch_or_default(:monit_bin_path, "monit")
|
|
22
|
+
sudo "#{monit_bin_path} restart backgroundjob_#{application}"
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
desc "Start backgroundrb (for application)"
|
|
26
|
+
task :start do
|
|
27
|
+
fetch_or_default(:monit_bin_path, "monit")
|
|
28
|
+
sudo "#{monit_bin_path} start backgroundjob_#{application}"
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
desc "Stop backgroundrb (for application)"
|
|
32
|
+
task :stop do
|
|
33
|
+
fetch_or_default(:monit_bin_path, "monit")
|
|
34
|
+
sudo "#{monit_bin_path} stop backgroundjob_#{application}"
|
|
35
|
+
end
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
end
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
namespace :backgroundrb do
|
|
2
|
+
|
|
3
|
+
namespace :monit do
|
|
4
|
+
|
|
5
|
+
desc <<-DESC
|
|
6
|
+
Generate and install backgroundrb (for application) monitrc.
|
|
7
|
+
|
|
8
|
+
"Source":#{link_to_source(__FILE__)}
|
|
9
|
+
DESC
|
|
10
|
+
task :install do
|
|
11
|
+
|
|
12
|
+
# Settings
|
|
13
|
+
fetch_or_default(:backgroundrb_pid_path, "#{shared_path}/pids/backgroundrb.pid")
|
|
14
|
+
fetch_or_default(:monit_conf_dir, "/etc/monit")
|
|
15
|
+
|
|
16
|
+
utils.install_template("backgroundrb/backgroundrb.monitrc.erb", "#{monit_conf_dir}/backgroundrb.monitrc")
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
desc "Restart backgroundrb (for application)"
|
|
20
|
+
task :restart do
|
|
21
|
+
fetch_or_default(:monit_bin_path, "monit")
|
|
22
|
+
sudo "#{monit_bin_path} restart backgroundrb_#{application}"
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
desc "Start backgroundrb (for application)"
|
|
26
|
+
task :start do
|
|
27
|
+
fetch_or_default(:monit_bin_path, "monit")
|
|
28
|
+
sudo "#{monit_bin_path} start backgroundrb_#{application}"
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
desc "Stop backgroundrb (for application)"
|
|
32
|
+
task :stop do
|
|
33
|
+
fetch_or_default(:monit_bin_path, "monit")
|
|
34
|
+
sudo "#{monit_bin_path} stop backgroundrb_#{application}"
|
|
35
|
+
end
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
end
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
namespace :database do
|
|
2
|
+
|
|
3
|
+
namespace :monit do
|
|
4
|
+
|
|
5
|
+
desc "Restart database (monit group)"
|
|
6
|
+
task :restart do
|
|
7
|
+
fetch_or_default(:monit_bin_path, "monit")
|
|
8
|
+
sudo "#{monit_bin_path} -g database restart all"
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
desc "Start database (monit group)"
|
|
12
|
+
task :start do
|
|
13
|
+
fetch_or_default(:monit_bin_path, "monit")
|
|
14
|
+
sudo "#{monit_bin_path} -g database start all"
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
desc "Stop database (monit group)"
|
|
18
|
+
task :stop do
|
|
19
|
+
fetch_or_default(:monit_bin_path, "monit")
|
|
20
|
+
sudo "#{monit_bin_path} -g database stop all"
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
end
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
namespace :memcached do
|
|
2
|
+
|
|
3
|
+
namespace :monit do
|
|
4
|
+
|
|
5
|
+
desc <<-DESC
|
|
6
|
+
Generate and install memcached monitrc.
|
|
7
|
+
"Source":#{link_to_source(__FILE__)}
|
|
8
|
+
DESC
|
|
9
|
+
task :install do
|
|
10
|
+
|
|
11
|
+
# Settings
|
|
12
|
+
fetch_or_default(:memcached_pid_path, "/var/run/memcached.pid")
|
|
13
|
+
fetch_or_default(:memcached_port, 11211)
|
|
14
|
+
fetch_or_default(:monit_conf_dir, "/etc/monit")
|
|
15
|
+
|
|
16
|
+
put template.load("memcached/memcached.monitrc.erb"), "/tmp/memcached.monitrc"
|
|
17
|
+
run_via "install -o root /tmp/memcached.monitrc #{monit_conf_dir}/memcached.monitrc"
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
end
|
|
@@ -0,0 +1,58 @@
|
|
|
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_arg(:merb_nodes, "Number of nodes in merb cluster")
|
|
12
|
+
task_arg(:merb_port, "Starting port")
|
|
13
|
+
task_arg(:monit_conf_dir, "Monit config directory", :default => "/etc/monit")
|
|
14
|
+
task_arg(:merb_pid_dir, "Merb pid directory", :default => Proc.new {"#{shared_path}/pids"}, :default_desc => "\#{shared_path}/pids")
|
|
15
|
+
task_arg(:merb_monitrc_template, "Merb monitrc template", :default => "merb/merb.monitrc.erb")
|
|
16
|
+
task :setup do
|
|
17
|
+
|
|
18
|
+
processes = []
|
|
19
|
+
ports = (0...merb_nodes).collect { |i| merb_port + i }
|
|
20
|
+
ports.each do |port|
|
|
21
|
+
|
|
22
|
+
pid_path = "#{merb_pid_dir}/merb.#{port}.pid"
|
|
23
|
+
|
|
24
|
+
start = "/etc/init.d/#{merb_initscript_name} start_only #{port}"
|
|
25
|
+
stop = "/etc/init.d/#{merb_initscript_name} stop_only #{port}"
|
|
26
|
+
|
|
27
|
+
processes << { :port => port, :start => start, :stop => stop, :pid_path => pid_path }
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
set :processes, processes
|
|
31
|
+
|
|
32
|
+
utils.install_template(merb_monitrc_template, "#{monit_conf_dir}/#{merb_application}.monitrc")
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
desc "Restart merb (for application)"
|
|
36
|
+
task :restart do
|
|
37
|
+
fetch_or_default(:monit_bin_path, "monit")
|
|
38
|
+
fetch_or_default(:merb_application, "merb_#{application}")
|
|
39
|
+
sudo "#{monit_bin_path} -g #{merb_application} restart all"
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
desc "Start merb (for application)"
|
|
43
|
+
task :start do
|
|
44
|
+
fetch_or_default(:monit_bin_path, "monit")
|
|
45
|
+
fetch_or_default(:merb_application, "merb_#{application}")
|
|
46
|
+
sudo "#{monit_bin_path} -g #{merb_application} start all"
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
desc "Stop merb (for application)"
|
|
50
|
+
task :stop do
|
|
51
|
+
fetch_or_default(:monit_bin_path, "monit")
|
|
52
|
+
fetch_or_default(:merb_application, "merb_#{application}")
|
|
53
|
+
sudo "#{monit_bin_path} -g #{merb_application} stop all"
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
end
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
namespace :mongrel do
|
|
2
|
+
|
|
3
|
+
namespace :cluster do
|
|
4
|
+
|
|
5
|
+
namespace :monit do
|
|
6
|
+
|
|
7
|
+
desc <<-DESC
|
|
8
|
+
Create monit configuration for mongrel cluster.
|
|
9
|
+
"Source":#{link_to_source(__FILE__)}
|
|
10
|
+
DESC
|
|
11
|
+
task :setup do
|
|
12
|
+
|
|
13
|
+
# See http://www.igvita.com/2006/11/07/monit-makes-mongrel-play-nice/
|
|
14
|
+
|
|
15
|
+
# TODO: For depends on memcached setting
|
|
16
|
+
# See http://blog.labratz.net/articles/2007/5/1/monit-for-your-uptime
|
|
17
|
+
|
|
18
|
+
# Settings
|
|
19
|
+
fetch(:mongrel_size)
|
|
20
|
+
fetch(:mongrel_port)
|
|
21
|
+
fetch_or_default(:mongrel_application, Proc.new { "mongrel_cluster_#{fetch(:application)}" })
|
|
22
|
+
fetch_or_default(:mongrel_bin_path, "/usr/bin/mongrel_rails")
|
|
23
|
+
fetch_or_default(:mongrel_config_script, nil)
|
|
24
|
+
fetch_or_default(:monit_conf_dir, "/etc/monit")
|
|
25
|
+
fetch_or_default(:mongrel_pid_dir, "#{shared_path}/pids")
|
|
26
|
+
|
|
27
|
+
processes = []
|
|
28
|
+
ports = (0...mongrel_size).collect { |i| mongrel_port + i }
|
|
29
|
+
ports.each do |port|
|
|
30
|
+
|
|
31
|
+
pid_path = "#{mongrel_pid_dir}/#{mongrel_application}.#{port}.pid"
|
|
32
|
+
|
|
33
|
+
default_options = [
|
|
34
|
+
[ "-d" ],
|
|
35
|
+
[ "-e", "production" ],
|
|
36
|
+
[ "-a", "127.0.0.1" ],
|
|
37
|
+
[ "-c", current_path ],
|
|
38
|
+
[ "--user", user ],
|
|
39
|
+
[ "--group", user ],
|
|
40
|
+
[ "-p", port ],
|
|
41
|
+
[ "-P", pid_path ],
|
|
42
|
+
[ "-l", "log/#{mongrel_application}.#{port}.log" ]
|
|
43
|
+
]
|
|
44
|
+
|
|
45
|
+
default_options << [ "-S", mongrel_config_script ] if mongrel_config_script
|
|
46
|
+
|
|
47
|
+
start_options = default_options.collect { |a| a.join(" ") }.join(" ")
|
|
48
|
+
#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"
|
|
49
|
+
stop_options = "-p #{port} -P #{pid_path}"
|
|
50
|
+
|
|
51
|
+
processes << { :port => port, :start_options => start_options, :stop_options => stop_options, :name => mongrel_bin_path, :pid_path => pid_path }
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
set :processes, processes
|
|
55
|
+
|
|
56
|
+
put template.load("mongrel/mongrel_cluster.monitrc.erb"), "/tmp/#{mongrel_application}.monitrc"
|
|
57
|
+
sudo "install -o root /tmp/#{mongrel_application}.monitrc #{monit_conf_dir}/#{mongrel_application}.monitrc"
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
desc "Restart mongrel cluster (for application)"
|
|
61
|
+
task :restart do
|
|
62
|
+
fetch_or_default(:monit_bin_path, "monit")
|
|
63
|
+
fetch_or_default(:mongrel_application, Proc.new { "mongrel_cluster_#{fetch(:application)}" })
|
|
64
|
+
sudo "#{monit_bin_path} -g #{mongrel_application} restart all"
|
|
65
|
+
end
|
|
66
|
+
|
|
67
|
+
desc "Start mongrel cluster (for application)"
|
|
68
|
+
task :start do
|
|
69
|
+
fetch_or_default(:monit_bin_path, "monit")
|
|
70
|
+
fetch_or_default(:mongrel_application, Proc.new { "mongrel_cluster_#{fetch(:application)}" })
|
|
71
|
+
sudo "#{monit_bin_path} -g #{mongrel_application} start all"
|
|
72
|
+
end
|
|
73
|
+
|
|
74
|
+
desc "Stop mongrel cluster (for application)"
|
|
75
|
+
task :stop do
|
|
76
|
+
fetch_or_default(:monit_bin_path, "monit")
|
|
77
|
+
fetch_or_default(:mongrel_application, Proc.new { "mongrel_cluster_#{fetch(:application)}" })
|
|
78
|
+
sudo "#{monit_bin_path} -g #{mongrel_application} stop all"
|
|
79
|
+
end
|
|
80
|
+
|
|
81
|
+
end
|
|
82
|
+
|
|
83
|
+
end
|
|
84
|
+
|
|
85
|
+
end
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
namespace :mysql do
|
|
2
|
+
|
|
3
|
+
namespace :monit do
|
|
4
|
+
|
|
5
|
+
desc <<-DESC
|
|
6
|
+
Install mysql monit hooks.
|
|
7
|
+
|
|
8
|
+
"Source":#{link_to_source(__FILE__)}
|
|
9
|
+
DESC
|
|
10
|
+
task_arg(:mysql_pid_path, "Path to mysql pid file", :default => "/var/run/mysqld/mysqld.pid")
|
|
11
|
+
task_arg(:mysql_port, "Mysql port", :default => 3306)
|
|
12
|
+
task_arg(:monit_conf_dir, "Monitrd directory", :default => "/etc/monit")
|
|
13
|
+
task :install do
|
|
14
|
+
put template.load("mysql/mysql.monitrc.erb", binding), "/tmp/mysql.monitrc"
|
|
15
|
+
run_via "install -o root /tmp/mysql.monitrc #{monit_conf_dir}/mysql.monitrc"
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
end
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
namespace :nginx do
|
|
2
|
+
|
|
3
|
+
namespace :monit do
|
|
4
|
+
|
|
5
|
+
desc <<-DESC
|
|
6
|
+
Install nginx monit hooks.
|
|
7
|
+
|
|
8
|
+
"Source":#{link_to_source(__FILE__)}
|
|
9
|
+
DESC
|
|
10
|
+
task_arg(:nginx_pid_path, "Path to nginx pid file", :default => "/var/run/nginx.pid")
|
|
11
|
+
task_arg(:monit_conf_dir, "Destination for monitrc", :default => "/etc/monit")
|
|
12
|
+
task :install do
|
|
13
|
+
put template.load("nginx/nginx.monitrc.erb", binding), "/tmp/nginx.monitrc"
|
|
14
|
+
run_via "install -o root /tmp/nginx.monitrc #{monit_conf_dir}/nginx.monitrc"
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
desc "Restart nginx (through monit)"
|
|
18
|
+
task :restart do
|
|
19
|
+
fetch_or_default(:monit_bin_path, "monit")
|
|
20
|
+
sudo "#{monit_bin_path} restart nginx"
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
desc "Start nginx (through monit)"
|
|
24
|
+
task :start do
|
|
25
|
+
fetch_or_default(:monit_bin_path, "monit")
|
|
26
|
+
sudo "#{monit_bin_path} start nginx"
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
desc "Stop nginx (through monit)"
|
|
30
|
+
task :stop do
|
|
31
|
+
fetch_or_default(:monit_bin_path, "monit")
|
|
32
|
+
sudo "#{monit_bin_path} stop nginx"
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
end
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
namespace :sphinx do
|
|
2
|
+
|
|
3
|
+
namespace :monit do
|
|
4
|
+
|
|
5
|
+
desc <<-DESC
|
|
6
|
+
Create monit configuration for sphinx.\n
|
|
7
|
+
|
|
8
|
+
"Source":#{link_to_source(__FILE__)}
|
|
9
|
+
DESC
|
|
10
|
+
task_arg(:monit_conf_dir, :default => "/etc/monit")
|
|
11
|
+
task_arg(:sphinx_pid_path, :default => Proc.new{"#{shared_path}/pids/searchd.pid"}, :default_desc => "\#{shared_path}/pids/searchd.pid")
|
|
12
|
+
task :setup do
|
|
13
|
+
put template.load("sphinx/sphinx.monitrc.erb"), "/tmp/sphinx_#{application}.monitrc"
|
|
14
|
+
sudo "install -o root /tmp/sphinx_#{application}.monitrc #{monit_conf_dir}/sphinx_#{application}.monitrc"
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
desc "Restart sphinx application (through monit)"
|
|
18
|
+
task :restart do
|
|
19
|
+
fetch_or_default(:monit_bin_path, "monit")
|
|
20
|
+
sudo "#{monit_bin_path} restart sphinx_#{application}"
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
desc "Start sphinx application (through monit)"
|
|
24
|
+
task :start do
|
|
25
|
+
fetch_or_default(:monit_bin_path, "monit")
|
|
26
|
+
sudo "#{monit_bin_path} start sphinx_#{application}"
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
desc "Stop sphinx application (through monit)"
|
|
30
|
+
task :stop do
|
|
31
|
+
fetch_or_default(:monit_bin_path, "monit")
|
|
32
|
+
sudo "#{monit_bin_path} stop sphinx_#{application}"
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
end
|