grosser-cap-recipes 0.2.19

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/README.textile ADDED
@@ -0,0 +1,257 @@
1
+ h1. cap-recipes
2
+
3
+ h2. INSTALLATION
4
+
5
+ * gem sources -a http://gems.github.com/
6
+ * sudo gem install nesquena-cap-recipes
7
+
8
+ h2. DESCRIPTION
9
+
10
+ This is a collection of capistrano recipes which will grow to encompass many useful recipes.
11
+ The intended use for these recipes is for a ruby project which deploys using Phusion Passenger and caches using memcached.
12
+ In addition, recipes for the management of various daemon processes will be included as needed.
13
+ Feel free to contribute to this and make it better!
14
+ Any of the recipes can be used on their own (TODO).
15
+
16
+ Currently included:
17
+
18
+ * Phusion Passenger (Setup and Deployment)
19
+ * Apache Server
20
+ * Memcache Process
21
+ * Juggernaut Daemon
22
+ * Backgroundrb Server
23
+
24
+ h2. SYNOPSIS
25
+
26
+ To include any of these into your deploy.rb configuration file for Capistrano:
27
+
28
+ require 'cap_recipes/tasks/passenger'
29
+ require 'cap_recipes/tasks/rails'
30
+ require 'cap_recipes/tasks/apache'
31
+ require 'cap_recipes/tasks/backgroundrb'
32
+ require 'cap_recipes/tasks/juggernaut'
33
+ require 'cap_recipes/tasks/memcache'
34
+
35
+ Or to include and activate all of them:
36
+
37
+ require 'cap_recipes'
38
+
39
+ By default, these recipes will include both tasks for managing (start/stop/restart) as well as tasks for installing when available.
40
+ The recipes also include hooks which tie all the recipes into the deployment process as appropriate.
41
+
42
+ If you wish to cherry-pick specific tasks, you can also include the management tasks, installation tasks and deploy hooks seperately.
43
+
44
+ require 'cap_recipes/tasks/memcache/install.rb' # memcache installation tasks
45
+ require 'cap_recipes/tasks/memcache/manage.rb' # memcache daemon management tasks
46
+ require 'cap_recipes/tasks/memcache/hooks.rb' # memcache deployment hooks
47
+
48
+ h2. USAGE
49
+
50
+ h3. Apache
51
+
52
+ h4. Configuration
53
+
54
+ * apache_init_path - the path to the init.d apache file [default: '/etc/init.d/apache2']
55
+
56
+ h4. Tasks
57
+
58
+ h5. manage.rb
59
+
60
+ apache
61
+ :stop
62
+ :start
63
+ :restart
64
+
65
+ h5. install.rb
66
+
67
+ apache
68
+ :install
69
+
70
+ h3. Passenger
71
+
72
+ h4. Configuration
73
+
74
+ * base_ruby_path - the base path to the ruby installation [default: "/usr"]
75
+ * local_ping_path - the localhost path to ping to start passenger [default: "http://localhost"]
76
+
77
+ The following files and folders are expected to exist:
78
+ * "#{base_ruby_path}/lib/ruby"
79
+ * "#{base_ruby_path}/bin/ruby"
80
+ * "#{base_ruby_path}/bin/gem"
81
+
82
+ h4. Tasks
83
+
84
+ h5. manage.rb
85
+
86
+ deploy
87
+ :start
88
+ :stop
89
+ :restart
90
+ :with_migrations
91
+
92
+ h5. install.rb
93
+
94
+ passenger
95
+ :install
96
+
97
+ h3. Rails
98
+
99
+ h4. Tasks
100
+
101
+ h5. tasks.rb
102
+
103
+ rails
104
+ :symlink_db_config
105
+ :repair_permissions
106
+ :tail - tail production log
107
+ :ping - ping the server to start it
108
+ sweep
109
+ :cache
110
+ :log
111
+
112
+ h5. hooks.rb
113
+
114
+ after "deploy:update_code", "rails:symlink_db_config" # copy database.yml file to release path
115
+ after "deploy:update_code", "rails:sweep:cache" # clear cache after updating code
116
+ after "deploy:restart" , "rails:repair_permissions" # fix the permissions to work properly
117
+ after "deploy:restart" , "rails:ping" # ping passenger to start the rails instance
118
+
119
+ h3. Backgroundrb
120
+
121
+ h4. Configuration
122
+
123
+ * backgroundrb_log - the path to the backgroundrb log file
124
+ * backgroundrb_host - the background host machine ip [default: 'localhost']
125
+ * backgroundrb_env - the rails environment [default: 'production']
126
+
127
+ h4. Tasks
128
+
129
+ h5. manage.rb
130
+
131
+ backgroundrb
132
+ :stop
133
+ :start
134
+ :restart
135
+ :symlink_config
136
+ :tail
137
+
138
+ h5. hooks.rb
139
+
140
+ after "deploy:update_code" , "backgroundrb:symlink_config" # copy backgroundrb config to release
141
+ after "deploy:restart" , "backgroundrb:restart" # restart backgroundrb daemon
142
+ after "backgroundrb:restart" , "backgroundrb:repair_permissions" # restart backgroundrb damon
143
+
144
+ h3. Juggernaut
145
+
146
+ h4. Configuration
147
+
148
+ * juggernaut_config - path to juggernaut config file [default: "#{current_path}/config/juggernaut.yml"]
149
+ * juggernaut_pid - path to juggernaut pid file [default: "#{current_path}/tmp/pids/juggernaut.pid"]
150
+ * juggernaut_log - path to juggernaut log file [default: "#{current_path}/log/juggernaut.log"]
151
+
152
+ h4. Tasks
153
+
154
+ h5. manage.rb
155
+
156
+ juggernaut
157
+ :start
158
+ :stop
159
+ :restart
160
+ :symlink_config
161
+ :tail
162
+
163
+ h5. hooks.rb
164
+
165
+ after "deploy:update_code", "juggernaut:symlink_config" # copy juggernaut.yml to release
166
+ after "deploy:restart" , "juggernaut:restart" # restart juggernaut daemon
167
+
168
+ h3. Memcache
169
+
170
+ h4. Configuration
171
+
172
+ * memcache_init_path - path to memcache config file [default: "/etc/init.d/memcache"]
173
+
174
+ h4. Tasks
175
+
176
+ h5. manage.rb
177
+
178
+ memcache
179
+ :start
180
+ :stop
181
+ :restart
182
+
183
+ h5. install.rb
184
+
185
+ memcache
186
+ :install
187
+
188
+ h5. hooks
189
+
190
+ after "deploy:restart", "memcache:restart" # clear cache after updating code
191
+
192
+ h2. EXAMPLE
193
+
194
+ Here is a sample deploy.rb file using cap_recipes:
195
+
196
+ <pre>
197
+ <code>
198
+ # =============================================================================
199
+ # GENERAL SETTINGS
200
+ # =============================================================================
201
+
202
+ set :application, "app_name"
203
+ set :deploy_to, "/var/apps/#{application}"
204
+ set :scm, :git
205
+ set :repository, "git@repos.site.com:/home/git/repos.git"
206
+
207
+ # =============================================================================
208
+ # CAP RECIPES
209
+ # =============================================================================
210
+
211
+ # Note this happens after the general settings have been defined
212
+ require 'rubygems'
213
+ require 'cap_recipes'
214
+
215
+ # PASSENGER
216
+ set :base_ruby_path, '/opt/ruby-enterprise' # defaults to "/usr"
217
+ set :apache_init_path, '/etc/init.d/apache2' # defaults to "/etc/init.d/apache2"
218
+
219
+ # BACKGROUNDRB
220
+ set :backgroundrb_log, "/var/log/backgroundrb.log" # defaults to "#{release_path}/log/backgroundrb.log"
221
+ set :backgroundrb_host, "worker.site.com" # defaults to localhost
222
+ set :backgroundrb_env, "staging" # defaults to production
223
+
224
+ # JUGGERNAUT
225
+ set :juggernaut_config, "/some/path/juggernaut.yml" # defaults to "#{current_path}/config/juggernaut.yml"
226
+ set :juggernaut_pid, "/some/path/juggernaut.pid" # defaults to "#{current_path}/tmp/pids/juggernaut.pid"
227
+ set :juggernaut_log, "/var/log/juggernaut.log" # defaults to #{release_path}/log/juggernaut.log
228
+
229
+ # MEMCACHE
230
+ set :memcache_init_path, "/etc/init.d/memcache" # defaults to "/etc/init.d/memcache"
231
+ </code>
232
+ </pre>
233
+
234
+ h2. LICENSE:
235
+
236
+ (The MIT License)
237
+
238
+ Copyright (c) 2008 Nathan Esquenazi
239
+
240
+ Permission is hereby granted, free of charge, to any person obtaining
241
+ a copy of this software and associated documentation files (the
242
+ 'Software'), to deal in the Software without restriction, including
243
+ without limitation the rights to use, copy, modify, merge, publish,
244
+ distribute, sublicense, and/or sell copies of the Software, and to
245
+ permit persons to whom the Software is furnished to do so, subject to
246
+ the following conditions:
247
+
248
+ The above copyright notice and this permission notice shall be
249
+ included in all copies or substantial portions of the Software.
250
+
251
+ THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
252
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
253
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
254
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
255
+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
256
+ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
257
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/VERSION.yml ADDED
@@ -0,0 +1,4 @@
1
+ ---
2
+ :patch: 19
3
+ :major: 0
4
+ :minor: 2
@@ -0,0 +1,12 @@
1
+ Capistrano::Configuration.instance(true).load do
2
+
3
+ namespace :apache do
4
+
5
+ desc 'Installs apache 2 and development headers to compile passenger'
6
+ task :install, :roles => :web do
7
+ puts 'Installing apache 2'
8
+ try_sudo 'apt-get install apache2 apache2.2-common apache2-mpm-prefork apache2-utils libexpat1 ssl-cert libapr1 libapr1-dev libaprutil1 libmagic1 libpcre3 libpq5 openssl apache2-prefork-dev -y'
9
+ end
10
+
11
+ end
12
+ end
@@ -0,0 +1,26 @@
1
+ Capistrano::Configuration.instance(true).load do
2
+
3
+ set :apache_init_path, "/etc/init.d/apache2"
4
+
5
+ namespace :apache do
6
+
7
+ desc "Stops the apache web server"
8
+ task :stop, :roles => :web do
9
+ puts "Stopping the apache server"
10
+ sudo "#{apache_init_path} stop"
11
+ end
12
+
13
+ desc "Starts the apache web server"
14
+ task :start, :roles => :web do
15
+ puts "Starting the apache server"
16
+ sudo "#{apache_init_path} start"
17
+ end
18
+
19
+ desc "Restarts the apache web server"
20
+ task :restart, :roles => :web do
21
+ puts "Restarting the apache server"
22
+ sudo "#{apache_init_path} restart"
23
+ end
24
+
25
+ end
26
+ end
@@ -0,0 +1 @@
1
+ Dir[File.join(File.dirname(__FILE__), 'apache/*.rb')].sort.each { |lib| require lib }
@@ -0,0 +1,5 @@
1
+ Capistrano::Configuration.instance(true).load do
2
+ after "deploy:update_code" , "backgroundrb:symlink_config"
3
+ after "deploy:restart" , "backgroundrb:restart"
4
+ after "backgroundrb:restart" , "backgroundrb:repair_permissions"
5
+ end
@@ -0,0 +1,63 @@
1
+ require 'yaml'
2
+
3
+ Capistrano::Configuration.instance(true).load do
4
+ set :backgroundrb_host, 'localhost'
5
+ set :backgroundrb_env , 'production'
6
+
7
+ namespace :backgroundrb do
8
+ # ===============================================================
9
+ # PROCESS MANAGEMENT
10
+ # ===============================================================
11
+
12
+ desc "Stops the backgroundrb worker processes"
13
+ task :stop, :roles => :app do
14
+ run "cd #{current_path} && #{sudo} ruby script/backgroundrb stop -e #{backgroundrb_env}"
15
+ end
16
+
17
+ desc "Starts the backgroundrb worker processes"
18
+ task :start, :roles => :app do
19
+ run "cd #{current_path} && #{sudo} nohup ruby script/backgroundrb start -e #{backgroundrb_env}"
20
+ end
21
+
22
+ desc "Restarts a running backgroundrb server."
23
+ task :restart, :roles => :app do
24
+ backgroundrb.stop
25
+ sleep(5) # sleep for 5 seconds to make sure the server has mopped up everything
26
+ backgroundrb.start
27
+ end
28
+
29
+ # ===============================================================
30
+ # PROCESS CONFIGURATION
31
+ # ===============================================================
32
+
33
+ desc "Creates configuration file for the backgroundrb server"
34
+ task :configure, :roles => :app do
35
+ config = { :backgroundrb => {:ip => backgroundrb_host, :port => backgroundrb_port, :environment => backgroundrb_env} }
36
+ backgroundrb_yml = config.to_yaml
37
+
38
+ run "if [ ! -d #{shared_path}/config ]; then mkdir #{shared_path}/config; fi"
39
+ put(backgroundrb_yml, "#{shared_path}/config/backgroundrb.yml", :mode => 0644)
40
+ end
41
+
42
+ # ===============================================================
43
+ # FILE MANAGEMENT
44
+ # ===============================================================
45
+
46
+ desc "Symlinks the shared/config/backgroundrb yaml to release/config/"
47
+ task :symlink_config, :roles => :app do
48
+ run "ln -s #{shared_path}/config/backgroundrb.yml #{release_path}/config/backgroundrb.yml"
49
+ end
50
+
51
+ desc "Displays the backgroundrb log from the server"
52
+ task :tail do
53
+ stream "tail -f #{shared_path}/log/backgroundrb_#{backgroundrb_port}.log"
54
+ end
55
+
56
+ desc "Repair permissions to allow user to perform all actions"
57
+ task :repair_permissions, :roles => :app do
58
+ puts "Applying correct permissions to allow for proper command execution"
59
+ try_sudo "chown -R #{user}:#{user} #{current_path}"
60
+ try_sudo "chown -R #{user}:#{user} #{current_path}/tmp"
61
+ end
62
+ end
63
+ end
@@ -0,0 +1 @@
1
+ Dir[File.join(File.dirname(__FILE__), 'backgroundrb/*.rb')].sort.each { |lib| require lib }
@@ -0,0 +1,4 @@
1
+ Capistrano::Configuration.instance(true).load do
2
+ after "deploy:update_code", "juggernaut:symlink_config" # copy juggernaut.yml on update code
3
+ after "deploy:restart" , "juggernaut:restart" # restart juggernaut on app restart
4
+ end
@@ -0,0 +1,46 @@
1
+ Capistrano::Configuration.instance(true).load do
2
+ set :juggernaut_config, "#{current_path}/config/juggernaut.yml"
3
+ set :juggernaut_pid, "#{current_path}/tmp/pids/juggernaut.pid"
4
+ set :juggernaut_log, "#{current_path}/log/juggernaut.log"
5
+
6
+ namespace :juggernaut do
7
+
8
+ # ===============================================================
9
+ # PROCESS MANAGEMENT
10
+ # ===============================================================
11
+
12
+ desc "Starts the juggernaut push server"
13
+ task :start, :roles => :app do
14
+ puts "Starting juggernaut push server"
15
+ try_sudo "juggernaut -c #{juggernaut_config} -d --pid #{juggernaut_pid} --log #{juggernaut_log}"
16
+ end
17
+
18
+ desc "Stops the juggernaut push server"
19
+ task :stop, :roles => :app do
20
+ puts "Stopping juggernaut push server"
21
+ try_sudo "juggernaut -c #{juggernaut_config} -k * --pid #{juggernaut_pid} --log #{juggernaut_log}"
22
+ end
23
+
24
+ desc "Restarts the juggernaut push server"
25
+ task :restart, :roles => :app do
26
+ juggernaut.stop
27
+ juggernaut.start
28
+ end
29
+
30
+ # ===============================================================
31
+ # FILE MANAGEMENT
32
+ # ===============================================================
33
+
34
+ desc "Symlinks the shared/config/juggernaut yaml to release/config/"
35
+ task :symlink_config, :roles => :app do
36
+ try_sudo "ln -s #{shared_path}/config/juggernaut.yml #{release_path}/config/juggernaut.yml"
37
+ end
38
+
39
+ desc "Displays the juggernaut log from the server"
40
+ task :tail, :roles => :app do
41
+ stream "tail -f #{shared_path}/log/juggernaut.log"
42
+ end
43
+
44
+ end
45
+
46
+ end
@@ -0,0 +1 @@
1
+ Dir[File.join(File.dirname(__FILE__), 'juggernaut/*.rb')].sort.each { |lib| require lib }
@@ -0,0 +1,5 @@
1
+ Capistrano::Configuration.instance(true).load do
2
+
3
+ after "deploy:restart", "memcache:restart" # clear cache after updating code
4
+
5
+ end
@@ -0,0 +1,20 @@
1
+ Capistrano::Configuration.instance(true).load do
2
+
3
+ set :memcache_init_path, "/etc/init.d/memcached"
4
+
5
+ # ===============================================================
6
+ # SERVER MANAGEMENT
7
+ # ===============================================================
8
+
9
+ namespace :memcache do
10
+
11
+ desc 'Installs memcache and the ruby gem'
12
+ task :install, :roles => :app do
13
+ puts 'Installing memcache'
14
+ try_sudo 'apt-get install memcached'
15
+ try_sudo "#{base_ruby_path}/bin/gem install memcache-client --no-ri --no-rdoc"
16
+ memcache.start
17
+ end
18
+
19
+ end
20
+ end
@@ -0,0 +1,28 @@
1
+ Capistrano::Configuration.instance(true).load do
2
+
3
+ set :memcache_init_path, "/etc/init.d/memcached"
4
+
5
+ namespace :memcache do
6
+
7
+ desc "Stops the memcache server"
8
+ task :stop, :roles => :app do
9
+ puts "Stopping the memcache server"
10
+ try_sudo "nohup /etc/init.d/memcached stop &"
11
+ end
12
+
13
+ desc "Starts the memcache server"
14
+ task :start, :roles => :app do
15
+ puts "Starting the memcache server"
16
+ try_sudo "nohup /etc/init.d/memcached start &"
17
+ end
18
+
19
+ desc "Restarts the memcache server"
20
+ task :restart, :roles => :app do
21
+ puts "Restarting the memcache server"
22
+ memcache.stop
23
+ sleep(3) # sleep for 3 seconds to make sure the server has mopped up everything
24
+ memcache.start
25
+ end
26
+
27
+ end
28
+ end
@@ -0,0 +1 @@
1
+ Dir[File.join(File.dirname(__FILE__), 'memcache/*.rb')].sort.each { |lib| require lib }
@@ -0,0 +1,49 @@
1
+ require 'cap_recipes/tasks/with_scope.rb'
2
+
3
+ #TODO add something like require that a task named apache:restart exists
4
+ Capistrano::Configuration.instance(true).load do
5
+ set :base_ruby_path, '/usr'
6
+
7
+ namespace :passenger do
8
+ desc "Installs Phusion Passenger"
9
+ task :install, :roles => :web do
10
+ puts 'Installing passenger module'
11
+ enable_apache_module
12
+ update_config
13
+ end
14
+
15
+ desc "Setup Passenger Module"
16
+ task :enable_apache_module, :roles => :web do
17
+ sudo "#{base_ruby_path}/bin/gem install passenger --no-ri --no-rdoc"
18
+ sudo "#{base_ruby_path}/bin/passenger-install-apache2-module", :pty => true do |ch, stream, data|
19
+ if data =~ /Press\sEnter\sto\scontinue/ || data =~ /Press\sENTER\sto\scontinue/
20
+ ch.send_data("\n")
21
+ else
22
+ Capistrano::Configuration.default_io_proc.call(ch, stream, data)
23
+ end
24
+ end
25
+ end
26
+
27
+ desc "Configure Passenger"
28
+ task :update_config, :roles => :web do
29
+ version = 'ERROR' # default
30
+
31
+ # passenger (2.X.X, 1.X.X)
32
+ run("gem list | grep passenger") do |ch, stream, data|
33
+ version = data.sub(/passenger \(([^,]+).*?\)/,"\\1").strip
34
+ end
35
+
36
+ puts " passenger version #{version} configured"
37
+
38
+ passenger_config =<<-EOF
39
+ LoadModule passenger_module #{base_ruby_path}/lib/ruby/gems/1.8/gems/passenger-#{version}/ext/apache2/mod_passenger.so
40
+ PassengerRoot #{base_ruby_path}/lib/ruby/gems/1.8/gems/passenger-#{version}
41
+ PassengerRuby #{base_ruby_path}/bin/ruby
42
+ EOF
43
+
44
+ put passenger_config, "/tmp/passenger"
45
+ sudo "mv /tmp/passenger /etc/apache2/conf.d/passenger"
46
+ apache.restart
47
+ end
48
+ end
49
+ end
@@ -0,0 +1,41 @@
1
+ require 'cap_recipes/tasks/with_scope.rb'
2
+
3
+ Capistrano::Configuration.instance(true).load do
4
+ namespace :deploy do
5
+
6
+ desc "Default deploy action"
7
+ task :default, :roles => :web do
8
+ with_role(:web) do
9
+ update
10
+ restart
11
+ end
12
+ end
13
+
14
+ desc "Stops the phusion passenger server"
15
+ task :stop, :roles => :web do
16
+ puts "Stopping rails web server"
17
+ apache.stop
18
+ end
19
+
20
+ desc "Starts the phusion passenger server"
21
+ task :start, :roles => :web do
22
+ puts "Starting rails web server"
23
+ apache.start
24
+ end
25
+
26
+ desc "Restarts the phusion passenger server"
27
+ task :restart, :roles => :web do
28
+ run "touch #{current_path}/tmp/restart.txt"
29
+ end
30
+
31
+ desc "Update code on server, apply migrations, and restart passenger server"
32
+ task :with_migrations, :roles => :web do
33
+ with_role(:web) do
34
+ deploy.update
35
+ deploy.migrate
36
+ deploy.restart
37
+ end
38
+ end
39
+
40
+ end
41
+ end
@@ -0,0 +1 @@
1
+ Dir[File.join(File.dirname(__FILE__), 'passenger/*.rb')].sort.each { |lib| require lib }
@@ -0,0 +1,8 @@
1
+ require 'cap_recipes/tasks/with_scope.rb'
2
+
3
+ Capistrano::Configuration.instance(true).load do
4
+ after "deploy:update_code", "rails:symlink_db_config" # copy database.yml file to release path
5
+ after "deploy:update_code", "rails:sweep:cache" # clear cache after updating code
6
+ after "deploy:restart" , "rails:repair_permissions" # fix the permissions to work properly
7
+ after "deploy:restart" , "rails:ping" # ping passenger to start the rails instance
8
+ end
@@ -0,0 +1,53 @@
1
+ require 'cap_recipes/tasks/with_scope.rb'
2
+
3
+ Capistrano::Configuration.instance(true).load do
4
+ set :local_ping_path, 'http://localhost'
5
+
6
+ namespace :rails do
7
+ # ===============================================================
8
+ # UTILITY TASKS
9
+ # ===============================================================
10
+ desc "Symlinks the shared/config/database yaml to release/config/"
11
+ task :symlink_db_config, :roles => :web do
12
+ puts "Copying database configuration to release path"
13
+ try_sudo "rm #{release_path}/config/database.yml -f"
14
+ try_sudo "ln -s #{shared_path}/config/database.yml #{release_path}/config/database.yml"
15
+ end
16
+
17
+ desc "Repair permissions to allow user to perform all actions"
18
+ task :repair_permissions, :roles => :web do
19
+ puts "Applying correct permissions to allow for proper command execution"
20
+ try_sudo "chmod -R 744 #{current_path}/log #{current_path}/tmp"
21
+ try_sudo "chown -R #{user}:#{user} #{current_path}"
22
+ try_sudo "chown -R #{user}:#{user} #{current_path}/tmp"
23
+ end
24
+
25
+ desc "Displays the production log from the server locally"
26
+ task :tail, :roles => :web do
27
+ stream "tail -f #{shared_path}/log/production.log"
28
+ end
29
+
30
+ desc "Pings localhost to startup server"
31
+ task :ping, :roles => :web do
32
+ puts "Pinging the web server to start it"
33
+ run "wget -O /dev/null #{local_ping_path} 2>/dev/null"
34
+ end
35
+
36
+ # ===============================================================
37
+ # MAINTENANCE TASKS
38
+ # ===============================================================
39
+ namespace :sweep do
40
+ desc "Clear file-based fragment and action caching"
41
+ task :log, :roles => :web do
42
+ puts "Sweeping all the log files"
43
+ run "cd #{current_path} && #{sudo} rake log:clear RAILS_ENV=production"
44
+ end
45
+
46
+ desc "Clear file-based fragment and action caching"
47
+ task :cache, :roles => :web do
48
+ puts "Sweeping the fragment and action cache stores"
49
+ run "cd #{release_path} && #{sudo} rake tmp:cache:clear RAILS_ENV=production"
50
+ end
51
+ end
52
+ end
53
+ end
@@ -0,0 +1 @@
1
+ Dir[File.join(File.dirname(__FILE__), 'rails/*.rb')].sort.each { |lib| require lib }
@@ -0,0 +1,22 @@
1
+ # role = :app
2
+ def with_role(role, &block)
3
+ original, ENV['HOSTS'] = ENV['HOSTS'], find_servers(:roles => role).map{|d| d.host}.join(",")
4
+ begin
5
+ yield
6
+ ensure
7
+ ENV['HOSTS'] = original
8
+ end
9
+ end
10
+
11
+ # options = { :user => 'xxxxx', :password => 'xxxxx' }
12
+ def with_credentials(options={}, &block)
13
+ original_username, original_password = user, password
14
+ begin
15
+ set :user, options[:user] || original_username
16
+ set :password, options[:password] || original_password
17
+ yield
18
+ ensure
19
+ set :user, original_username
20
+ set :password, original_password
21
+ end
22
+ end
@@ -0,0 +1 @@
1
+ Dir[File.join(File.dirname(__FILE__), 'cap_recipes/tasks/*.rb')].sort.each { |lib| require lib }
@@ -0,0 +1,5 @@
1
+ require File.dirname(__FILE__) + '/test_helper'
2
+
3
+ class CapRecipesTest < Test::Unit::TestCase
4
+
5
+ end
@@ -0,0 +1,10 @@
1
+ require 'rubygems'
2
+ require 'test/unit'
3
+ require 'shoulda'
4
+ require 'mocha'
5
+
6
+ $LOAD_PATH.unshift(File.dirname(__FILE__))
7
+ require 'cap_recipes'
8
+
9
+ class Test::Unit::TestCase
10
+ end
metadata ADDED
@@ -0,0 +1,86 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: grosser-cap-recipes
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.2.19
5
+ platform: ruby
6
+ authors:
7
+ - Nathan Esquenazi
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+
12
+ date: 2009-02-15 00:00:00 -08:00
13
+ default_executable:
14
+ dependencies: []
15
+
16
+ description: Battle-tested capistrano recipes for passenger, apache, and more
17
+ email: nesquena@gmail.com
18
+ executables: []
19
+
20
+ extensions: []
21
+
22
+ extra_rdoc_files: []
23
+
24
+ files:
25
+ - README.textile
26
+ - VERSION.yml
27
+ - lib/cap_recipes
28
+ - lib/cap_recipes/tasks
29
+ - lib/cap_recipes/tasks/apache
30
+ - lib/cap_recipes/tasks/apache/install.rb
31
+ - lib/cap_recipes/tasks/apache/manage.rb
32
+ - lib/cap_recipes/tasks/apache.rb
33
+ - lib/cap_recipes/tasks/backgroundrb
34
+ - lib/cap_recipes/tasks/backgroundrb/hooks.rb
35
+ - lib/cap_recipes/tasks/backgroundrb/manage.rb
36
+ - lib/cap_recipes/tasks/backgroundrb.rb
37
+ - lib/cap_recipes/tasks/juggernaut
38
+ - lib/cap_recipes/tasks/juggernaut/hooks.rb
39
+ - lib/cap_recipes/tasks/juggernaut/manage.rb
40
+ - lib/cap_recipes/tasks/juggernaut.rb
41
+ - lib/cap_recipes/tasks/memcache
42
+ - lib/cap_recipes/tasks/memcache/hooks.rb
43
+ - lib/cap_recipes/tasks/memcache/install.rb
44
+ - lib/cap_recipes/tasks/memcache/manage.rb
45
+ - lib/cap_recipes/tasks/memcache.rb
46
+ - lib/cap_recipes/tasks/passenger
47
+ - lib/cap_recipes/tasks/passenger/install.rb
48
+ - lib/cap_recipes/tasks/passenger/manage.rb
49
+ - lib/cap_recipes/tasks/passenger.rb
50
+ - lib/cap_recipes/tasks/rails
51
+ - lib/cap_recipes/tasks/rails/hooks.rb
52
+ - lib/cap_recipes/tasks/rails/tasks.rb
53
+ - lib/cap_recipes/tasks/rails.rb
54
+ - lib/cap_recipes/tasks/with_scope.rb
55
+ - lib/cap_recipes.rb
56
+ - test/cap_recipes_test.rb
57
+ - test/test_helper.rb
58
+ has_rdoc: true
59
+ homepage: http://github.com/nesquena/cap-recipes
60
+ post_install_message:
61
+ rdoc_options:
62
+ - --inline-source
63
+ - --charset=UTF-8
64
+ require_paths:
65
+ - lib
66
+ required_ruby_version: !ruby/object:Gem::Requirement
67
+ requirements:
68
+ - - ">="
69
+ - !ruby/object:Gem::Version
70
+ version: "0"
71
+ version:
72
+ required_rubygems_version: !ruby/object:Gem::Requirement
73
+ requirements:
74
+ - - ">="
75
+ - !ruby/object:Gem::Version
76
+ version: "0"
77
+ version:
78
+ requirements: []
79
+
80
+ rubyforge_project:
81
+ rubygems_version: 1.2.0
82
+ signing_key:
83
+ specification_version: 2
84
+ summary: Battle-tested capistrano recipes for passenger, apache, and more
85
+ test_files: []
86
+