crazycode-cap-recipes 0.3.37
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/LICENSE +20 -0
- data/README.textile +586 -0
- data/Rakefile +57 -0
- data/VERSION.yml +5 -0
- data/bin/cap-recipes +4 -0
- data/cap-recipes.gemspec +128 -0
- data/examples/advanced/deploy.rb +39 -0
- data/examples/advanced/deploy/experimental.rb +14 -0
- data/examples/advanced/deploy/production.rb +20 -0
- data/examples/simple/deploy.rb +36 -0
- data/lib/cap_recipes.rb +1 -0
- data/lib/cap_recipes/tasks/apache.rb +1 -0
- data/lib/cap_recipes/tasks/apache/install.rb +16 -0
- data/lib/cap_recipes/tasks/apache/manage.rb +26 -0
- data/lib/cap_recipes/tasks/aptitude.rb +1 -0
- data/lib/cap_recipes/tasks/aptitude/manage.rb +32 -0
- data/lib/cap_recipes/tasks/backgroundrb.rb +1 -0
- data/lib/cap_recipes/tasks/backgroundrb/hooks.rb +5 -0
- data/lib/cap_recipes/tasks/backgroundrb/manage.rb +64 -0
- data/lib/cap_recipes/tasks/bundler.rb +1 -0
- data/lib/cap_recipes/tasks/bundler/manage.rb +31 -0
- data/lib/cap_recipes/tasks/delayed_job.rb +1 -0
- data/lib/cap_recipes/tasks/delayed_job/hooks.rb +5 -0
- data/lib/cap_recipes/tasks/delayed_job/manage.rb +34 -0
- data/lib/cap_recipes/tasks/ec2/install.rb +32 -0
- data/lib/cap_recipes/tasks/ec2/manage.rb +32 -0
- data/lib/cap_recipes/tasks/gitosis.rb +1 -0
- data/lib/cap_recipes/tasks/gitosis/install.rb +58 -0
- data/lib/cap_recipes/tasks/gitosis/manage.rb +3 -0
- data/lib/cap_recipes/tasks/hudson.rb +1 -0
- data/lib/cap_recipes/tasks/hudson/manage.rb +33 -0
- data/lib/cap_recipes/tasks/jetty.rb +1 -0
- data/lib/cap_recipes/tasks/jetty/install.rb +33 -0
- data/lib/cap_recipes/tasks/jetty/manage.rb +34 -0
- data/lib/cap_recipes/tasks/jetty/web.rb +98 -0
- data/lib/cap_recipes/tasks/juggernaut.rb +3 -0
- data/lib/cap_recipes/tasks/juggernaut/hooks.rb +4 -0
- data/lib/cap_recipes/tasks/juggernaut/manage.rb +56 -0
- data/lib/cap_recipes/tasks/maven.rb +85 -0
- data/lib/cap_recipes/tasks/memcache.rb +3 -0
- data/lib/cap_recipes/tasks/memcache/hooks.rb +5 -0
- data/lib/cap_recipes/tasks/memcache/install.rb +15 -0
- data/lib/cap_recipes/tasks/memcache/manage.rb +37 -0
- data/lib/cap_recipes/tasks/mongodb.rb +1 -0
- data/lib/cap_recipes/tasks/mongodb/install.rb +137 -0
- data/lib/cap_recipes/tasks/mongodb/manage.rb +27 -0
- data/lib/cap_recipes/tasks/passenger.rb +1 -0
- data/lib/cap_recipes/tasks/passenger/install.rb +72 -0
- data/lib/cap_recipes/tasks/passenger/manage.rb +23 -0
- data/lib/cap_recipes/tasks/rails.rb +1 -0
- data/lib/cap_recipes/tasks/rails/hooks.rb +6 -0
- data/lib/cap_recipes/tasks/rails/manage.rb +51 -0
- data/lib/cap_recipes/tasks/ruby.rb +1 -0
- data/lib/cap_recipes/tasks/ruby/install.rb +16 -0
- data/lib/cap_recipes/tasks/rubygems.rb +1 -0
- data/lib/cap_recipes/tasks/rubygems/install.rb +22 -0
- data/lib/cap_recipes/tasks/rubygems/manage.rb +43 -0
- data/lib/cap_recipes/tasks/templates/hudson.erb +85 -0
- data/lib/cap_recipes/tasks/templates/mongod.conf.erb +89 -0
- data/lib/cap_recipes/tasks/templates/mongodb.init.erb +73 -0
- data/lib/cap_recipes/tasks/templates/mongodb.repo.erb +4 -0
- data/lib/cap_recipes/tasks/templates/mongos.init.erb +69 -0
- data/lib/cap_recipes/tasks/templates/tomcat.erb +95 -0
- data/lib/cap_recipes/tasks/thinking_sphinx.rb +1 -0
- data/lib/cap_recipes/tasks/thinking_sphinx/hooks.rb +4 -0
- data/lib/cap_recipes/tasks/thinking_sphinx/install.rb +17 -0
- data/lib/cap_recipes/tasks/thinking_sphinx/manage.rb +65 -0
- data/lib/cap_recipes/tasks/tomcat.rb +1 -0
- data/lib/cap_recipes/tasks/tomcat/install.rb +43 -0
- data/lib/cap_recipes/tasks/tomcat/manage.rb +34 -0
- data/lib/cap_recipes/tasks/tomcat/war.rb +98 -0
- data/lib/cap_recipes/tasks/utilities.rb +172 -0
- data/lib/cap_recipes/tasks/whenever.rb +1 -0
- data/lib/cap_recipes/tasks/whenever/hooks.rb +5 -0
- data/lib/cap_recipes/tasks/whenever/manage.rb +8 -0
- data/lib/cap_recipes/tasks/yum.rb +1 -0
- data/lib/cap_recipes/tasks/yum/manage.rb +30 -0
- data/lib/capify.rb +35 -0
- data/lib/templates/Capfile.tt +4 -0
- data/lib/templates/deploy.rb.tt +30 -0
- data/spec/cap/all/Capfile +2 -0
- data/spec/cap/helper.rb +3 -0
- data/spec/cap_recipes_spec.rb +56 -0
- data/spec/spec_helper.rb +37 -0
- data/specs.watchr +35 -0
- metadata +155 -0
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
require 'fileutils'
|
|
2
|
+
require 'capistrano/recipes/deploy/scm'
|
|
3
|
+
require File.expand_path(File.dirname(__FILE__) + '/utilities')
|
|
4
|
+
require File.expand_path(File.dirname(__FILE__) + '/tomcat')
|
|
5
|
+
|
|
6
|
+
Capistrano::Configuration.instance(true).load do
|
|
7
|
+
|
|
8
|
+
set :source_path, "source"
|
|
9
|
+
|
|
10
|
+
set :scm, :subversion
|
|
11
|
+
|
|
12
|
+
set :source_dir do
|
|
13
|
+
"#{Dir.pwd}/#{source_path}"
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
desc "default mvn task. do svn update, package, and then deploy to tomcat"
|
|
17
|
+
task :default do
|
|
18
|
+
update_source
|
|
19
|
+
build
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
desc "update code from scm from maven build."
|
|
23
|
+
task :update_source do
|
|
24
|
+
on_rollback { system "rm -rf #{source_dir}; true" }
|
|
25
|
+
if Dir.exists?(source_dir)
|
|
26
|
+
system source.sync(real_revision, source_dir)
|
|
27
|
+
else
|
|
28
|
+
system "mkdir #{source_dir}"
|
|
29
|
+
system source.checkout(real_revision, source_dir)
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
desc "build use maven2"
|
|
34
|
+
task :build do
|
|
35
|
+
system "cd #{source_dir}; mvn -Dmaven.test.skip=true clean install"
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
task :clean do
|
|
39
|
+
if Dir.exists?("#{source_dir}/.svn")
|
|
40
|
+
system "cd #{source_dir}; mvn clean"
|
|
41
|
+
end
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
desc "deploy all module"
|
|
45
|
+
task :mdeploy do
|
|
46
|
+
if exists?(:modules)
|
|
47
|
+
#default
|
|
48
|
+
modules.each do |key, module_setting|
|
|
49
|
+
set :scm, :none
|
|
50
|
+
set :application, module_setting[:name]
|
|
51
|
+
set :module_dir, module_setting[:module_dir].nil? ? name : module_setting[:module_dir]
|
|
52
|
+
set :war, "#{source_dir}/#{module_dir}/target/#{module_setting[:war_name]}"
|
|
53
|
+
set :webserver, module_setting[:webserver]
|
|
54
|
+
|
|
55
|
+
set :scm, :none
|
|
56
|
+
set :deploy_via, :copy
|
|
57
|
+
set :use_sudo, true
|
|
58
|
+
|
|
59
|
+
deploy.update_code :roles => webserver
|
|
60
|
+
end
|
|
61
|
+
end
|
|
62
|
+
end
|
|
63
|
+
desc "deploy all module"
|
|
64
|
+
task :msetup do
|
|
65
|
+
if exists?(:modules)
|
|
66
|
+
#default
|
|
67
|
+
modules.each do |key, module_setting|
|
|
68
|
+
puts "do #{key}...#{module_setting[:name]}"
|
|
69
|
+
set :scm, :none
|
|
70
|
+
set :application, module_setting[:name]
|
|
71
|
+
set :module_dir, module_setting[:module_dir].nil? ? name : module_setting[:module_dir]
|
|
72
|
+
set :war, "#{source_dir}/#{module_dir}/target/#{module_setting[:war_name]}"
|
|
73
|
+
set :webserver, module_setting[:webserver]
|
|
74
|
+
|
|
75
|
+
set :scm, :none
|
|
76
|
+
set :deploy_via, :copy
|
|
77
|
+
set :use_sudo, true
|
|
78
|
+
|
|
79
|
+
deploy.setup :roles => webserver
|
|
80
|
+
end
|
|
81
|
+
end
|
|
82
|
+
end
|
|
83
|
+
|
|
84
|
+
end
|
|
85
|
+
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/../utilities')
|
|
2
|
+
|
|
3
|
+
Capistrano::Configuration.instance(true).load do
|
|
4
|
+
namespace :memcache do
|
|
5
|
+
|
|
6
|
+
desc 'Installs memcache and the ruby gem'
|
|
7
|
+
task :install, :roles => :app do
|
|
8
|
+
puts 'Installing memcache'
|
|
9
|
+
utilities.apt_install 'memcached'
|
|
10
|
+
try_sudo "#{base_ruby_path}/bin/gem install memcache-client --no-ri --no-rdoc"
|
|
11
|
+
memcache.start
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
end
|
|
15
|
+
end
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/../utilities')
|
|
2
|
+
|
|
3
|
+
Capistrano::Configuration.instance(true).load do
|
|
4
|
+
|
|
5
|
+
set :memcache_init_path, "/etc/init.d/memcached"
|
|
6
|
+
set :memcache_role, :app
|
|
7
|
+
|
|
8
|
+
namespace :memcache do
|
|
9
|
+
|
|
10
|
+
desc "Stops the memcache server"
|
|
11
|
+
task :stop, :roles => memcache_role do
|
|
12
|
+
utilities.with_role(memcache_role) do
|
|
13
|
+
puts "Stopping the memcache server"
|
|
14
|
+
try_sudo "killall -s TERM memcached; true"
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
desc "Starts the memcache server"
|
|
19
|
+
task :start, :roles => memcache_role do
|
|
20
|
+
utilities.with_role(memcache_role) do
|
|
21
|
+
puts "Starting the memcache server"
|
|
22
|
+
try_sudo "nohup /etc/init.d/memcached start"
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
desc "Restarts the memcache server"
|
|
27
|
+
task :restart, :roles => memcache_role do
|
|
28
|
+
utilities.with_role(memcache_role) do
|
|
29
|
+
puts "Restarting the memcache server"
|
|
30
|
+
memcache.stop
|
|
31
|
+
sleep(3) # sleep for 3 seconds to make sure the server has mopped up everything
|
|
32
|
+
memcache.start
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
end
|
|
37
|
+
end
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
Dir[File.join(File.dirname(__FILE__), 'mongodb/*.rb')].sort.each { |lib| require lib }
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/../utilities')
|
|
2
|
+
require File.expand_path(File.dirname(__FILE__) + '/manage')
|
|
3
|
+
|
|
4
|
+
Capistrano::Configuration.instance(true).load do
|
|
5
|
+
default_run_options[:pty] = true
|
|
6
|
+
|
|
7
|
+
#set :mongodb_data_path, "/data/db"
|
|
8
|
+
set :mongodb_bin_path, "/opt/mongo"
|
|
9
|
+
|
|
10
|
+
set :mongodb_nodename, "node0"
|
|
11
|
+
|
|
12
|
+
set :mongodb_name do
|
|
13
|
+
"mongod_#{mongodb_nodename}"
|
|
14
|
+
end
|
|
15
|
+
set :mongod_conf do
|
|
16
|
+
"/etc/#{mongodb_name}.conf"
|
|
17
|
+
end
|
|
18
|
+
set :mongodb_init do
|
|
19
|
+
"/etc/init.d/#{mongodb_name}"
|
|
20
|
+
end
|
|
21
|
+
set :mongodb_data_path do
|
|
22
|
+
"/var/data/#{mongodb_name}"
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
set :mongodb_port, 27017
|
|
26
|
+
set :mongodb_is_configsvr, false
|
|
27
|
+
|
|
28
|
+
set :mongos_name, "mongos"
|
|
29
|
+
set :mongos_init, "/etc/init.d/mongos"
|
|
30
|
+
set :mongos_log_path, "/var/log/mongos"
|
|
31
|
+
set :mongos_config_db, "127.0.0.1:27019"
|
|
32
|
+
|
|
33
|
+
namespace :mongodb do
|
|
34
|
+
desc "Installs mongodb binaries and all dependencies"
|
|
35
|
+
task :install, :role => :app do
|
|
36
|
+
utilities.apt_install "tcsh scons g++ libpcre++-dev"
|
|
37
|
+
utilities.apt_install "libboost1.37-dev libreadline-dev xulrunner-dev"
|
|
38
|
+
mongodb.make_spidermonkey
|
|
39
|
+
mongodb.make_mongodb
|
|
40
|
+
mongodb.setup_db_path
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
task :make_spidermonkey, :role => :app do
|
|
44
|
+
run "mkdir -p ~/tmp"
|
|
45
|
+
run "cd ~/tmp; wget ftp://ftp.mozilla.org/pub/mozilla.org/js/js-1.7.0.tar.gz"
|
|
46
|
+
run "cd ~/tmp; tar -zxvf js-1.7.0.tar.gz"
|
|
47
|
+
run "cd ~/tmp/js/src; export CFLAGS=\"-DJS_C_STRINGS_ARE_UTF8\""
|
|
48
|
+
run "cd ~/tmp/js/src; #{sudo} make -f Makefile.ref"
|
|
49
|
+
run "cd ~/tmp/js/src; #{sudo} JS_DIST=/usr make -f Makefile.ref export"
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
task :make_mongodb, :role => :app do
|
|
53
|
+
sudo "rm -rf ~/tmp/mongo"
|
|
54
|
+
run "cd ~/tmp; git clone git://github.com/mongodb/mongo.git"
|
|
55
|
+
run "cd ~/tmp/mongo; #{sudo} scons all"
|
|
56
|
+
run "cd ~/tmp/mongo; #{sudo} scons --prefix=#{mongodb_bin_path} install"
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
task :setup_db_path, :role => :app do
|
|
60
|
+
sudo "mkdir -p #{mongodb_data_path}"
|
|
61
|
+
mongodb.start
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
# for centos
|
|
65
|
+
desc "setup mongodb use yum"
|
|
66
|
+
task :yum_install, :role => :app do
|
|
67
|
+
put utilities.render("mongodb.repo", binding), "mongodb.repo.tmp"
|
|
68
|
+
sudo "cp mongodb.repo.tmp /etc/yum.repos.d/MongoDB.repo"
|
|
69
|
+
run "rm mongodb.repo.tmp"
|
|
70
|
+
|
|
71
|
+
sudo "yum update"
|
|
72
|
+
sudo "yum install mongo-stable-server"
|
|
73
|
+
end
|
|
74
|
+
|
|
75
|
+
desc "install mongo node"
|
|
76
|
+
task :install_node, :role => :app do
|
|
77
|
+
# create config file
|
|
78
|
+
put utilities.render("mongod.conf", binding), "mongod.conf.tmp"
|
|
79
|
+
put utilities.render("mongodb.init", binding), "mongodb.init.tmp"
|
|
80
|
+
sudo "cp mongod.conf.tmp #{mongod_conf}"
|
|
81
|
+
sudo "cp mongodb.init.tmp #{mongodb_init}"
|
|
82
|
+
sudo "chmod a+x #{mongodb_init}"
|
|
83
|
+
sudo "/sbin/chkconfig --add #{mongodb_name}"
|
|
84
|
+
run "rm mongod.conf.tmp"
|
|
85
|
+
run "rm mongodb.init.tmp"
|
|
86
|
+
|
|
87
|
+
sudo "mkdir -p #{mongodb_data_path}"
|
|
88
|
+
sudo "chown mongod:mongod #{mongodb_data_path}"
|
|
89
|
+
end
|
|
90
|
+
|
|
91
|
+
desc "install mongos"
|
|
92
|
+
task :install_mongos, :role => :app do
|
|
93
|
+
put utilities.render("mongos.init", binding), "mongos.init.tmp"
|
|
94
|
+
sudo "cp mongos.init.tmp #{mongos_init}"
|
|
95
|
+
sudo "chmod a+x #{mongos_init}"
|
|
96
|
+
sudo "/sbin/chkconfig --add #{mongos_name}"
|
|
97
|
+
run "rm mongos.init.tmp"
|
|
98
|
+
|
|
99
|
+
sudo "mkdir -p #{mongos_log_path}"
|
|
100
|
+
sudo "chown mongod:mongod #{mongodb_data_path}"
|
|
101
|
+
end
|
|
102
|
+
|
|
103
|
+
desc "node start"
|
|
104
|
+
task :node_start, :role => :app do
|
|
105
|
+
sudo "#{mongodb_init} start"
|
|
106
|
+
end
|
|
107
|
+
|
|
108
|
+
desc "node stop"
|
|
109
|
+
task :node_stop, :role => :app do
|
|
110
|
+
sudo "#{mongodb_init} stop"
|
|
111
|
+
end
|
|
112
|
+
|
|
113
|
+
desc "node status"
|
|
114
|
+
task :node_status, :role => :app do
|
|
115
|
+
sudo "ps auxH | grep mongo | wc -l"
|
|
116
|
+
sudo "#{mongodb_init} status"
|
|
117
|
+
end
|
|
118
|
+
|
|
119
|
+
desc "uninstall mongo node"
|
|
120
|
+
task :uninstall_node, :role => :app do
|
|
121
|
+
mongodb.node_stop
|
|
122
|
+
sudo "rm #{mongod_conf}"
|
|
123
|
+
sudo "rm #{mongodb_init}"
|
|
124
|
+
sudo "/sbin/chkconfig #{mongodb_name} off"
|
|
125
|
+
sudo "/sbin/chkconfig --del #{mongodb_name}"
|
|
126
|
+
end
|
|
127
|
+
|
|
128
|
+
desc "uninstall mongos"
|
|
129
|
+
task :uninstall_mongos, :role => :app do
|
|
130
|
+
mongodb.node_stop
|
|
131
|
+
sudo "rm #{mongos_init}"
|
|
132
|
+
sudo "/sbin/chkconfig #{mongos_name} off"
|
|
133
|
+
sudo "/sbin/chkconfig --del #{mongos_name}"
|
|
134
|
+
end
|
|
135
|
+
|
|
136
|
+
end
|
|
137
|
+
end
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/../utilities')
|
|
2
|
+
require File.expand_path(File.dirname(__FILE__) + '/install')
|
|
3
|
+
|
|
4
|
+
Capistrano::Configuration.instance(true).load do
|
|
5
|
+
set :mongodb_log, "/var/log/mongodb.log"
|
|
6
|
+
|
|
7
|
+
namespace :mongodb do
|
|
8
|
+
desc "Starts the mongodb server"
|
|
9
|
+
task :start, :role => :app do
|
|
10
|
+
sudo "#{mongodb_bin_path}/bin/mongod --fork --logpath #{mongodb_log} --logappend --dbpath #{mongodb_data_path}"
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
desc "Stop the mongodb server"
|
|
14
|
+
task :stop, :role => :app do
|
|
15
|
+
pid = capture("ps -o pid,command ax | grep mongod | awk '!/awk/ && !/grep/ {print $1}'")
|
|
16
|
+
sudo "kill -2 #{pid}" unless pid.strip.empty?
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
desc "Restart the mongodb server"
|
|
20
|
+
task :restart, :role => :app do
|
|
21
|
+
pid = capture("ps -o pid,command ax | grep mongod | awk '!/awk/ && !/grep/ {print $1}'")
|
|
22
|
+
mongodb.stop unless pid.strip.empty?
|
|
23
|
+
mongodb.start
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
end
|
|
27
|
+
end
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
Dir[File.join(File.dirname(__FILE__), 'passenger/*.rb')].sort.each { |lib| require lib }
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/../utilities')
|
|
2
|
+
require File.expand_path(File.dirname(__FILE__) + '/../apache/manage')
|
|
3
|
+
|
|
4
|
+
Capistrano::Configuration.instance(true).load do
|
|
5
|
+
set :base_ruby_path, '/usr'
|
|
6
|
+
set :confd_passenger_filename, 'passenger'
|
|
7
|
+
|
|
8
|
+
namespace :passenger do
|
|
9
|
+
desc "Installs Phusion Passenger"
|
|
10
|
+
task :install, :roles => :web do
|
|
11
|
+
puts 'Installing passenger module'
|
|
12
|
+
enable_apache_module
|
|
13
|
+
update_config
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
desc "install build-essentials and other packages"
|
|
18
|
+
task :install_build_essential do
|
|
19
|
+
utilities.apt_install 'build-essential'
|
|
20
|
+
utilities.apt_install 'apache2-prefork-dev'
|
|
21
|
+
utilities.apt_install 'libapr1-dev'
|
|
22
|
+
utilities.apt_install 'libaprutil1-dev'
|
|
23
|
+
end
|
|
24
|
+
before "passenger:install", "passenger:install_build_essential"
|
|
25
|
+
|
|
26
|
+
desc "Setup Passenger Module"
|
|
27
|
+
task :enable_apache_module, :roles => :web do
|
|
28
|
+
sudo "#{base_ruby_path}/bin/gem install passenger --no-ri --no-rdoc"
|
|
29
|
+
sudo "#{base_ruby_path}/bin/passenger-install-apache2-module --auto"
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
desc "Configure Passenger"
|
|
33
|
+
task :update_config, :roles => :web do
|
|
34
|
+
version = 'ERROR' # default
|
|
35
|
+
|
|
36
|
+
# passenger (2.X.X, 1.X.X)
|
|
37
|
+
run("gem list | grep passenger") do |ch, stream, data|
|
|
38
|
+
version = data.sub(/passenger \(([^,]+).*?\)/,"\\1").strip
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
puts " passenger version #{version} configured"
|
|
42
|
+
|
|
43
|
+
passenger_config =<<-EOF
|
|
44
|
+
LoadModule passenger_module #{base_ruby_path}/lib/ruby/gems/1.8/gems/passenger-#{version}/ext/apache2/mod_passenger.so
|
|
45
|
+
PassengerRoot #{base_ruby_path}/lib/ruby/gems/1.8/gems/passenger-#{version}
|
|
46
|
+
PassengerRuby #{base_ruby_path}/bin/ruby
|
|
47
|
+
EOF
|
|
48
|
+
|
|
49
|
+
put passenger_config, "/tmp/passenger"
|
|
50
|
+
sudo "mv /tmp/passenger /etc/apache2/conf.d/#{confd_passenger_filename}"
|
|
51
|
+
apache.restart
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
# if you want to add more options, try this, in your own conifg
|
|
55
|
+
# read this first... http://www.modrails.com/documentation/Users%20guide.html
|
|
56
|
+
# namespace :passenger do
|
|
57
|
+
# task :add_custom_configuration, :roles=>:web do
|
|
58
|
+
# #512 - 100(stack) - 4*100(instance)
|
|
59
|
+
# passenger_config = <<EOF
|
|
60
|
+
# PassengerMaxPoolSize 4
|
|
61
|
+
# PassengerPoolIdleTime 3000
|
|
62
|
+
# EOF
|
|
63
|
+
# put passenger_config, "/tmp/passenger"
|
|
64
|
+
# sudo "cat /tmp/passenger >> /etc/apache2/conf.d/passenger"
|
|
65
|
+
# apache.restart
|
|
66
|
+
# end
|
|
67
|
+
# end
|
|
68
|
+
# after "passenger:update_config", *%w(
|
|
69
|
+
# passenger:add_custom_configuration
|
|
70
|
+
# )
|
|
71
|
+
end
|
|
72
|
+
end
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
Capistrano::Configuration.instance(true).load do
|
|
2
|
+
namespace :deploy do
|
|
3
|
+
|
|
4
|
+
desc "Stops the phusion passenger server"
|
|
5
|
+
task :stop, :roles => :web do
|
|
6
|
+
puts "Stopping rails web server"
|
|
7
|
+
apache.stop
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
desc "Starts the phusion passenger server"
|
|
11
|
+
task :start, :roles => :web do
|
|
12
|
+
puts "Starting rails web server"
|
|
13
|
+
apache.start
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
desc "Restarts the phusion passenger server"
|
|
17
|
+
task :restart, :roles => :web do
|
|
18
|
+
puts "Restarting passenger by touching restart.txt"
|
|
19
|
+
run "touch #{current_path}/tmp/restart.txt"
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
end
|
|
23
|
+
end
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
Dir[File.join(File.dirname(__FILE__), 'rails/*.rb')].sort.each { |lib| require lib }
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
Capistrano::Configuration.instance(true).load do
|
|
2
|
+
after "deploy:update_code", "rails:symlink_db_config" # copy database.yml file to release path
|
|
3
|
+
after "deploy:update_code", "rails:sweep:cache" # clear cache after updating code
|
|
4
|
+
after "deploy:restart" , "rails:repair_permissions" # fix the permissions to work properly
|
|
5
|
+
after "deploy:restart" , "rails:ping" # ping passenger to start the rails instance
|
|
6
|
+
end
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
Capistrano::Configuration.instance(true).load do
|
|
2
|
+
set :local_ping_path, 'http://localhost'
|
|
3
|
+
|
|
4
|
+
namespace :rails do
|
|
5
|
+
# ===============================================================
|
|
6
|
+
# UTILITY TASKS
|
|
7
|
+
# ===============================================================
|
|
8
|
+
desc "Symlinks the shared/config/database yaml to release/config/"
|
|
9
|
+
task :symlink_db_config, :roles => :app do
|
|
10
|
+
puts "Copying database configuration to release path"
|
|
11
|
+
try_sudo "rm #{release_path}/config/database.yml -f"
|
|
12
|
+
try_sudo "ln -s #{shared_path}/config/database.yml #{release_path}/config/database.yml"
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
desc "Repair permissions to allow user to perform all actions"
|
|
16
|
+
task :repair_permissions, :roles => :app do
|
|
17
|
+
puts "Applying correct permissions to allow for proper command execution"
|
|
18
|
+
try_sudo "chmod -R 744 #{current_path}/log #{current_path}/tmp"
|
|
19
|
+
try_sudo "chown -R #{user}:#{user} #{current_path}"
|
|
20
|
+
try_sudo "chown -R #{user}:#{user} #{current_path}/tmp"
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
desc "Displays the production log from the server locally"
|
|
24
|
+
task :tail, :roles => :app do
|
|
25
|
+
stream "tail -f #{shared_path}/log/production.log"
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
desc "Pings localhost to startup server"
|
|
29
|
+
task :ping, :roles => :app do
|
|
30
|
+
puts "Pinging the web server to start it"
|
|
31
|
+
run "wget -O /dev/null #{local_ping_path} 2>/dev/null"
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
# ===============================================================
|
|
35
|
+
# MAINTENANCE TASKS
|
|
36
|
+
# ===============================================================
|
|
37
|
+
namespace :sweep do
|
|
38
|
+
desc "Clear file-based fragment and action caching"
|
|
39
|
+
task :log, :roles => :app do
|
|
40
|
+
puts "Sweeping all the log files"
|
|
41
|
+
run "cd #{current_path} && #{sudo} rake log:clear RAILS_ENV=production"
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
desc "Clear file-based fragment and action caching"
|
|
45
|
+
task :cache, :roles => :app do
|
|
46
|
+
puts "Sweeping the fragment and action cache stores"
|
|
47
|
+
run "cd #{release_path} && #{sudo} rake tmp:cache:clear RAILS_ENV=production"
|
|
48
|
+
end
|
|
49
|
+
end
|
|
50
|
+
end
|
|
51
|
+
end
|