capcake 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
data/LICENSE ADDED
@@ -0,0 +1,25 @@
1
+ Copyright (c) 2005-2009, WDT Media Corp (http://wdtmedia.net)
2
+ All rights reserved.
3
+
4
+ Redistribution and use in source and binary forms, with or without modification,
5
+ are permitted provided that the following conditions are met:
6
+
7
+ * Redistributions of source code must retain the above copyright notice,
8
+ this list of conditions and the following disclaimer.
9
+ * Redistributions in binary form must reproduce the above copyright notice,
10
+ this list of conditions and the following disclaimer in the documentation
11
+ and/or other materials provided with the distribution.
12
+ * Neither the name of Capcake, WDT Media, WDT Media Corp, nor the names of its contributors
13
+ may be used to endorse or promote products derived from this software
14
+ without specific prior written permission.
15
+
16
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
17
+ ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18
+ WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
19
+ IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
20
+ INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
21
+ BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
22
+ DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
23
+ OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
24
+ NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
25
+ EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
data/README.markdown ADDED
@@ -0,0 +1,99 @@
1
+ # capcake
2
+
3
+ Looking to deploy a [CakePHP](http://cakephp.org) application you've built? Capcake extends [Capistrano](http://capify.org), removing the *rails-ism*, replacing them by more *cake-ish* ones.
4
+
5
+ ## Installation
6
+
7
+ If you don't have Capistrano and/or Capcake already installed (basically, just the 1st time):
8
+
9
+ # gem install capistrano
10
+ # gem install capcake -s http://gemcutter.org
11
+
12
+ For every application you'll want to deploy:
13
+
14
+ # cd /path/to/app && capify .
15
+
16
+ This will create the following files in your project (don't forget to commit them!):
17
+
18
+ capfile
19
+ config/deploy.rb
20
+
21
+ Prepend your config/deploy.rb with the following lines:
22
+
23
+ require 'rubygems'
24
+ require 'capcake'
25
+
26
+ And make sure you start capcake on the last line of that same file:
27
+
28
+ capcake
29
+
30
+ You should then be able to proceed as you usually would. To familiarize yourself with the now modified list of tasks, you can get a full list with:
31
+
32
+ $ cap -T
33
+
34
+ ## Configuration
35
+
36
+ Before continuing, some changes to config/deploy.rb are necessary. First, your project's name:
37
+
38
+ set :application, "your_app_name"
39
+
40
+ Next, setting up the Git repository (make sure it's accessible by both your local machine and server your are deploying to):
41
+
42
+ set :repository, "git@domain.com:path/to/repo"
43
+
44
+ Now, to deploy from Git, and by following [GitHub's suggestion](http://github.com/guides/deploying-with-capistrano) (they must know what they are talking about), add a user (defaults to *deployer* by capcake's recipe) to your server(s) just for deployments. In this example, I will be using SSH keys instead of getting a Git password prompt. Local user's SSH key must be added to *deployer*'s ~/.ssh/authorized_keys for this to work as described.
45
+
46
+ ssh_options[:forward_agent] = true
47
+
48
+ We need to tell it where to deploy, using what methods:
49
+
50
+ server "www.domain.tld", :app, :db, :primary => true
51
+
52
+ And finally, some CakePHP related settings (if omitted, Capcake will NOT handle deploying CakePHP):
53
+
54
+ set :cake_branch, "1.3.0-alpha"
55
+
56
+ For this to work, *deployer*'s SSH keys must be added to the [Chaw](http://thechaw.com/users/account).
57
+
58
+ You can change the default values for the following variables also:
59
+
60
+ set :cake_branch, "1.2"
61
+ set :cake_path, "/path/to"
62
+ set :user, "your_username"
63
+ set :branch, "tag"
64
+
65
+ ## Deployment
66
+
67
+ The first time you are deploying, you need to run:
68
+
69
+ # cap deploy:setup
70
+
71
+ That should create on your server the following directory structure:
72
+
73
+ [deploy_to]
74
+ [deploy_to]/releases
75
+ [deploy_to]/shared
76
+ [deploy_to]/shared/cakephp
77
+ [deploy_to]/shared/system
78
+ [deploy_to]/shared/tmp
79
+
80
+ Finally, deploy:
81
+
82
+ # cap deploy
83
+
84
+ Which will change the directory structure to become:
85
+
86
+ [deploy_to]
87
+ [deploy_to]/current -> [deploy_to]/releases/20091013001122
88
+ [deploy_to]/releases
89
+ [deploy_to]/releases/20091013001122
90
+ [deploy_to]/releases/20091013001122/system -> [deploy_to]/shared/system
91
+ [deploy_to]/releases/20091013001122/tmp -> [deploy_to]/shared/tmp
92
+ [deploy_to]/shared
93
+ [deploy_to]/shared/cakephp
94
+ [deploy_to]/shared/system
95
+ [deploy_to]/shared/tmp
96
+
97
+ ## Bugs & Feedback
98
+
99
+ http://github.com/jadb/capcake/issues
data/lib/capcake.rb ADDED
@@ -0,0 +1,481 @@
1
+ # Capcake capistrano's recipe
2
+ #
3
+ # Author:: Jad Bitar (mailto:jadbitar@mac.com)
4
+ # Copyright:: Copyright (c) 2005-2009, WDT Media Corp (http://wdtmedia.net)
5
+ # License:: http://opensource.org/licenses/bsd-license.php The BSD License
6
+
7
+ Capistrano::Configuration.instance(:must_exist).load do
8
+
9
+ require 'capistrano/recipes/deploy/scm'
10
+ require 'capistrano/recipes/deploy/strategy'
11
+
12
+ # =========================================================================
13
+ # These variables may be set in the client capfile if their default values
14
+ # are not sufficient.
15
+ # =========================================================================
16
+
17
+ set :application, ""
18
+ set :branch, "master"
19
+ set :deploy_to, ""
20
+ set :keep_releases, 5
21
+ set :repository, ""
22
+ set :use_sudo, false
23
+ set :user, "deployer"
24
+
25
+ # =========================================================================
26
+ # These variables should NOT be changed unless you are very confident in
27
+ # what you are doing. Make sure you understand all the implications of your
28
+ # changes if you do decide to muck with these!
29
+ # =========================================================================
30
+
31
+ set :scm, :git
32
+ set :git_enable_submodules, 1
33
+ set :revision, source.head
34
+ set :deploy_via, :checkout
35
+ set :shared_children, %w(system tmp)
36
+
37
+ set :git_flag_quiet, ""
38
+
39
+ _cset(:cake_branch) { "" }
40
+ _cset(:cake_repo) { "dev@code.cakephp.org:cakephp.git" }
41
+ _cset :tmp_children, %w(cache logs sessions tests)
42
+ _cset :cache_children, %w(models persistent views)
43
+ _cset :logs_files, %w(debug error)
44
+
45
+ def capcake()
46
+ set :deploy_to, "/var/www/#{application}" if (deploy_to.empty?)
47
+ set(:current_path) { File.join(deploy_to, current_dir) }
48
+ set(:shared_path) { File.join(deploy_to, shared_dir) }
49
+ _cset(:cake_path) { shared_path }
50
+ _cset(:tmp_path) { File.join(shared_path, "tmp") }
51
+ _cset(:cache_path) { File.join(tmp_path, "cache") }
52
+ _cset(:logs_path) { File.join(tmp_path, "logs") }
53
+ end
54
+
55
+ # =========================================================================
56
+ # These are the tasks that are available to help with deploying web apps,
57
+ # and specifically, Rails applications. You can have cap give you a summary
58
+ # of them with `cap -T'.
59
+ # =========================================================================
60
+
61
+ namespace :deploy do
62
+ desc <<-DESC
63
+ Deploys your project. This calls `update'. Note that \
64
+ this will generally only work for applications that have already been deployed \
65
+ once. For a "cold" deploy, you'll want to take a look at the `deploy:cold' \
66
+ task, which handles the cold start specifically.
67
+ DESC
68
+ task :default do
69
+ update
70
+ end
71
+ desc <<-DESC
72
+ Prepares one or more servers for deployment. Before you can use any \
73
+ of the Capistrano deployment tasks with your project, you will need to \
74
+ make sure all of your servers have been prepared with `cap deploy:setup'. When \
75
+ you add a new server to your cluster, you can easily run the setup task \
76
+ on just that server by specifying the HOSTS environment variable:
77
+
78
+ $ cap HOSTS=new.server.com deploy:setup
79
+
80
+ It is safe to run this task on servers that have already been set up; it \
81
+ will not destroy any deployed revisions or data.
82
+ DESC
83
+ task :setup, :except => { :no_release => true } do
84
+ dirs = [deploy_to, releases_path, shared_path]
85
+ dirs += shared_children.map { |d| File.join(shared_path, d) }
86
+ tmp_dirs = tmp_children.map { |d| File.join(tmp_path, d) }
87
+ tmp_dirs += cache_children.map { |d| File.join(cache_path, d) }
88
+ run "#{try_sudo} mkdir -p #{(dirs + tmp_dirs).join(' ')} && #{try_sudo} chmod -R 777 #{tmp_path}" if (!user.empty?)
89
+ set :git_flag_quiet, "-q "
90
+ cake.setup if (!cake_branch.empty?)
91
+ end
92
+
93
+ desc <<-DESC
94
+ Copies your project and updates the symlink. It does this in a \
95
+ transaction, so that if either `update_code' or `symlink' fail, all \
96
+ changes made to the remote servers will be rolled back, leaving your \
97
+ system in the same state it was in before `update' was invoked. Usually, \
98
+ you will want to call `deploy' instead of `update', but `update' can be \
99
+ handy if you want to deploy, but not immediately restart your application.
100
+ DESC
101
+ task :update do
102
+ transaction do
103
+ update_code
104
+ symlink
105
+ end
106
+ end
107
+
108
+ desc <<-DESC
109
+ Copies your project to the remote servers. This is the first stage \
110
+ of any deployment; moving your updated code and assets to the deployment \
111
+ servers. You will rarely call this task directly, however; instead, you \
112
+ should call the `deploy' task (to do a complete deploy) or the `update' \
113
+ task (if you want to perform the `restart' task separately).
114
+
115
+ You will need to make sure you set the :scm variable to the source \
116
+ control software you are using (it defaults to :subversion), and the \
117
+ :deploy_via variable to the strategy you want to use to deploy (it \
118
+ defaults to :checkout).
119
+ DESC
120
+ task :update_code, :except => { :no_release => true } do
121
+ on_rollback { run "rm -rf #{release_path}; true" }
122
+ strategy.deploy!
123
+ finalize_update
124
+ end
125
+
126
+ desc <<-DESC
127
+ [internal] Touches up the released code. This is called by update_code \
128
+ after the basic deploy finishes. It assumes a Rails project was deployed, \
129
+ so if you are deploying something else, you may want to override this \
130
+ task with your own environment's requirements.
131
+
132
+ This task will make the release group-writable (if the :group_writable \
133
+ variable is set to true, which is the default). It will then set up \
134
+ symlinks to the shared directory for the log, system, and tmp/pids \
135
+ directories, and will lastly touch all assets in public/images, \
136
+ public/stylesheets, and public/javascripts so that the times are \
137
+ consistent (so that asset timestamping works). This touch process \
138
+ is only carried out if the :normalize_asset_timestamps variable is \
139
+ set to true, which is the default.
140
+ DESC
141
+ task :finalize_update, :except => { :no_release => true } do
142
+ run "chmod -R g+w #{latest_release}" if fetch(:group_writable, true)
143
+ end
144
+
145
+ desc <<-DESC
146
+ Updates the symlinks to the most recently deployed version. Capistrano works \
147
+ by putting each new release of your application in its own directory. When \
148
+ you deploy a new version, this task's job is to update the `current', \
149
+ `current/tmp', `current/webroot/system' symlinks to point at the new version. \
150
+
151
+ You will rarely need to call this task directly; instead, use the `deploy' \
152
+ task (which performs a complete deploy, including `restart') or the 'update' \
153
+ task (which does everything except `restart').
154
+ DESC
155
+ task :symlink, :except => { :no_release => true } do
156
+ on_rollback do
157
+ if previous_release
158
+ run "rm -f #{current_path}; ln -s #{previous_release} #{current_path}; ln -s #{shared_path}/system #{current_path}/webroot/system; ln -s #{shared_path}/tmp #{current_path}/tmp; true"
159
+ else
160
+ logger.important "no previous release to rollback to, rollback of symlink skipped"
161
+ end
162
+ end
163
+
164
+ run "rm -f #{current_path} && ln -s #{latest_release} #{current_path} && ln -s #{shared_path}/system #{current_path}/webroot/system && ln -s #{shared_path}/tmp #{current_path}/tmp"
165
+ end
166
+
167
+ desc <<-DESC
168
+ Copy files to the currently deployed version. This is useful for updating \
169
+ files piecemeal, such as when you need to quickly deploy only a single \
170
+ file. Some files, such as updated templates, images, or stylesheets, \
171
+ might not require a full deploy, and especially in emergency situations \
172
+ it can be handy to just push the updates to production, quickly.
173
+
174
+ To use this task, specify the files and directories you want to copy as a \
175
+ comma-delimited list in the FILES environment variable. All directories \
176
+ will be processed recursively, with all files being pushed to the \
177
+ deployment servers.
178
+
179
+ $ cap deploy:upload FILES=templates,controller.rb
180
+
181
+ Dir globs are also supported:
182
+
183
+ $ cap deploy:upload FILES='config/apache/*.conf'
184
+ DESC
185
+ task :upload, :except => { :no_release => true } do
186
+ files = (ENV["FILES"] || "").split(",").map { |f| Dir[f.strip] }.flatten
187
+ abort "Please specify at least one file or directory to update (via the FILES environment variable)" if files.empty?
188
+
189
+ files.each { |file| top.upload(file, File.join(current_path, file)) }
190
+ end
191
+
192
+ namespace :rollback do
193
+ desc <<-DESC
194
+ [internal] Points the current symlink at the previous revision.
195
+ This is called by the rollback sequence, and should rarely (if
196
+ ever) need to be called directly.
197
+ DESC
198
+ task :revision, :except => { :no_release => true } do
199
+ if previous_release
200
+ run "rm #{current_path}; ln -s #{previous_release} #{current_path}; ln -s #{shared_path}/system #{current_path}/webroot/system; ln -s #{shared_path}/tmp #{current_path}/tmp"
201
+ else
202
+ abort "could not rollback the code because there is no prior release"
203
+ end
204
+ end
205
+
206
+ desc <<-DESC
207
+ [internal] Removes the most recently deployed release.
208
+ This is called by the rollback sequence, and should rarely
209
+ (if ever) need to be called directly.
210
+ DESC
211
+ task :cleanup, :except => { :no_release => true } do
212
+ run "if [ `readlink #{current_path}` != #{current_release} ]; then rm -rf #{current_release}; fi"
213
+ end
214
+
215
+ desc <<-DESC
216
+ Rolls back to the previously deployed version. The `current' symlink will \
217
+ be updated to point at the previously deployed version, and then the \
218
+ current release will be removed from the servers.
219
+ DESC
220
+ task :code, :except => { :no_release => true } do
221
+ revision
222
+ cleanup
223
+ end
224
+
225
+ desc <<-DESC
226
+ Rolls back to a previous version and restarts. This is handy if you ever \
227
+ discover that you've deployed a lemon; `cap rollback' and you're right \
228
+ back where you were, on the previously deployed version.
229
+ DESC
230
+ task :default do
231
+ revision
232
+ cleanup
233
+ end
234
+ end
235
+
236
+ desc <<-DESC
237
+ Clean up old releases. By default, the last 5 releases are kept on each \
238
+ server (though you can change this with the keep_releases variable). All \
239
+ other deployed revisions are removed from the servers. By default, this \
240
+ will use sudo to clean up the old releases, but if sudo is not available \
241
+ for your environment, set the :use_sudo variable to false instead.
242
+ DESC
243
+ task :cleanup, :except => { :no_release => true } do
244
+ count = fetch(:keep_releases, 5).to_i
245
+ if count >= releases.length
246
+ logger.important "no old releases to clean up"
247
+ else
248
+ logger.info "keeping #{count} of #{releases.length} deployed releases"
249
+
250
+ directories = (releases - releases.last(count)).map { |release|
251
+ File.join(releases_path, release) }.join(" ")
252
+
253
+ try_sudo "rm -rf #{directories}"
254
+ end
255
+ end
256
+
257
+ desc <<-DESC
258
+ Test deployment dependencies. Checks things like directory permissions, \
259
+ necessary utilities, and so forth, reporting on the things that appear to \
260
+ be incorrect or missing. This is good for making sure a deploy has a \
261
+ chance of working before you actually run `cap deploy'.
262
+
263
+ You can define your own dependencies, as well, using the `depend' method:
264
+
265
+ depend :remote, :gem, "tzinfo", ">=0.3.3"
266
+ depend :local, :command, "svn"
267
+ depend :remote, :directory, "/u/depot/files"
268
+ DESC
269
+ task :check, :except => { :no_release => true } do
270
+ dependencies = strategy.check!
271
+
272
+ other = fetch(:dependencies, {})
273
+ other.each do |location, types|
274
+ types.each do |type, calls|
275
+ if type == :gem
276
+ dependencies.send(location).command(fetch(:gem_command, "gem")).or("`gem' command could not be found. Try setting :gem_command")
277
+ end
278
+
279
+ calls.each do |args|
280
+ dependencies.send(location).send(type, *args)
281
+ end
282
+ end
283
+ end
284
+
285
+ if dependencies.pass?
286
+ puts "You appear to have all necessary dependencies installed"
287
+ else
288
+ puts "The following dependencies failed. Please check them and try again:"
289
+ dependencies.reject { |d| d.pass? }.each do |d|
290
+ puts "--> #{d.message}"
291
+ end
292
+ abort
293
+ end
294
+ end
295
+
296
+ desc <<-DESC
297
+ Deploys and starts a `cold' application. This is useful if you have never \
298
+ deployed your application before. It currently runs `deploy:setup` followed \
299
+ by `deploy:update`. \
300
+ (This is still an experimental feature, and is subject to change without \
301
+ notice!)
302
+ DESC
303
+ task :cold do
304
+ setup
305
+ update
306
+ end
307
+
308
+ namespace :pending do
309
+ desc <<-DESC
310
+ Displays the `diff' since your last deploy. This is useful if you want \
311
+ to examine what changes are about to be deployed. Note that this might \
312
+ not be supported on all SCM's.
313
+ DESC
314
+ task :diff, :except => { :no_release => true } do
315
+ system(source.local.diff(current_revision))
316
+ end
317
+
318
+ desc <<-DESC
319
+ Displays the commits since your last deploy. This is good for a summary \
320
+ of the changes that have occurred since the last deploy. Note that this \
321
+ might not be supported on all SCM's.
322
+ DESC
323
+ task :default, :except => { :no_release => true } do
324
+ from = source.next_revision(current_revision)
325
+ system(source.local.log(from))
326
+ end
327
+ end
328
+
329
+ namespace :web do
330
+ desc <<-DESC
331
+ Present a maintenance page to visitors. Disables your application's web \
332
+ interface by writing a "maintenance.html" file to each web server. The \
333
+ servers must be configured to detect the presence of this file, and if \
334
+ it is present, always display it instead of performing the request.
335
+
336
+ By default, the maintenance page will just say the site is down for \
337
+ "maintenance", and will be back "shortly", but you can customize the \
338
+ page by specifying the REASON and UNTIL environment variables:
339
+
340
+ $ cap deploy:web:disable \\
341
+ REASON="hardware upgrade" \\
342
+ UNTIL="12pm Central Time"
343
+
344
+ Further customization will require that you write your own task.
345
+ DESC
346
+ task :disable, :roles => :web, :except => { :no_release => true } do
347
+ require 'erb'
348
+ on_rollback { run "rm #{shared_path}/system/maintenance.html" }
349
+
350
+ warn <<-EOHTACCESS
351
+
352
+ # Please add something like this to your site's htaccess to redirect users to the maintenance page.
353
+ # More Info: http://www.shiftcommathree.com/articles/make-your-rails-maintenance-page-respond-with-a-503
354
+
355
+ ErrorDocument 503 /system/maintenance.html
356
+ RewriteEngine On
357
+ RewriteCond %{REQUEST_URI} !\.(css|gif|jpg|png)$
358
+ RewriteCond %{DOCUMENT_ROOT}/system/maintenance.html -f
359
+ RewriteCond %{SCRIPT_FILENAME} !maintenance.html
360
+ RewriteRule ^.*$ - [redirect=503,last]
361
+ EOHTACCESS
362
+
363
+ reason = ENV['REASON']
364
+ deadline = ENV['UNTIL']
365
+
366
+ template = File.read(File.join(File.dirname(__FILE__), "templates", "maintenance.rhtml"))
367
+ result = ERB.new(template).result(binding)
368
+
369
+ put(result, "#{shared_path}/system/maintenance.html", :mode => 0644, :via => :scp)
370
+ end
371
+
372
+ desc <<-DESC
373
+ Makes the application web-accessible again. Removes the \
374
+ "maintenance.html" page generated by deploy:web:disable, which (if your \
375
+ web servers are configured correctly) will make your application \
376
+ web-accessible again.
377
+ DESC
378
+ task :enable, :roles => :web, :except => { :no_release => true } do
379
+ run "rm #{shared_path}/system/maintenance.html"
380
+ end
381
+ end
382
+
383
+ desc <<-DESC
384
+ Quick server(s) reset. For now, it deletes all files/folders in :deploy_to \
385
+ (This is still an experimental feature, and is subject to change without \
386
+ notice!) \
387
+
388
+ Used only when first testing setup deploy recipes and want to quickly \
389
+ reset servers.
390
+ DESC
391
+ task :destroy do
392
+ set(:confirm) do
393
+ Capistrano::CLI.ui.ask "This will delete your project on all servers. Are you sure you wish to continue? [Y/n]"
394
+ end
395
+ run "#{try_sudo} rm -rf #{deploy_to}/*" if (confirm == "Y")
396
+ end
397
+
398
+ end
399
+
400
+ namespace :cake do
401
+
402
+ desc <<-DESC
403
+ Prepares server for deployment of a CakePHP application. \
404
+
405
+ By default, it will create a shallow clone of the CakePHP repository \
406
+ inside #{shared_path}/cakephp and run deploy:cake:update.
407
+
408
+ For more info about shallow clones: \
409
+ http://www.kernel.org/pub/software/scm/git/docs/git-clone.html \
410
+
411
+ Further customization will require that you write your own task.
412
+ DESC
413
+ desc "Prepares server for deployment of a CakePHP application"
414
+ task :setup do
415
+ run "cd #{cake_path} && git clone --depth 1 #{cake_repo}"
416
+ set :git_flag_quiet, "-q "
417
+ update
418
+ end
419
+ desc <<-DESC
420
+ Force CakePHP installation to checkout a new branch/tag. \
421
+
422
+ By default, it will checkout the :cake_branch you set in \
423
+ deploy.rb, but you can change that on runtime by specifying \
424
+ the BRANCH environment variable:
425
+
426
+ $ cap deploy:cake:update \\
427
+ BRANCH="1.3.0-alpha"
428
+
429
+ Further customization will require that you write your own task.
430
+ DESC
431
+ task :update do
432
+ set :cake_branch, ENV['BRANCH'] if ENV.has_key?('BRANCH')
433
+ stream "cd #{cake_path}/cakephp && git checkout #{git_flag_quiet}#{cake_branch}"
434
+ end
435
+
436
+ namespace :cache do
437
+ desc <<-DESC
438
+ Clears CakePHP's APP/tmp/cache and its sub-directories.
439
+
440
+ Recursively finds all files in :cache_path and runs `rm -f` on each. If a file \
441
+ is renamed/removed after it was found but before it removes it, no error \
442
+ will prompt (-ignore_readdir_race). If symlinks are found, they will not be followed
443
+
444
+ You will rarely need to call this task directly; instead, use the `deploy' \
445
+ task (which performs a complete deploy, including `cake:cache:clear')
446
+ DESC
447
+ task :clear, :roles => :web, :except => { :no_release => true } do
448
+ run "#{try_sudo} find -P #{cache_path} -ignore_readdir_race -type f -name '*' -exec rm -f {} \\;"
449
+ end
450
+ end
451
+
452
+ namespace :logs do
453
+ desc <<-DESC
454
+ Clears CakePHP's APP/tmp/logs and its sub-directories
455
+
456
+ Recursively finds all files in :logs_path and runs `rm -f` on each. If a file \
457
+ is renamed/removed after it was found but before it removes it, no error \
458
+ will prompt (-ignore_readdir_race). If symlinks are found, they will not be followed
459
+
460
+ DESC
461
+ task :clear, :roles => :web, :except => { :no_release => true } do
462
+ run "#{try_sudo} find -P #{logs_path} -ignore_readdir_race -type f -name '*' -exec rm -f {} \\;"
463
+ end
464
+ desc <<-DESC
465
+ Streams the result of `tail -f` on all :logs_files \
466
+
467
+ By default, the files are `debug` and `error`. You can add your own \
468
+ in config/deploy.rb
469
+
470
+ set :logs_files %w(debug error my_log_file)
471
+
472
+ DESC
473
+ task :tail, :roles => :web, :except => { :no_release => true } do
474
+ files = logs_files.map { |d| File.join(logs_path, d) }
475
+ stream "#{try_sudo} tail -f #{files.join(' ')}"
476
+ end
477
+ end
478
+
479
+ end
480
+
481
+ end # Capistrano::Configuration.instance(:must_exist).load do
@@ -0,0 +1,52 @@
1
+ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
2
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
3
+
4
+ <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
5
+
6
+ <head>
7
+ <meta http-equiv="content-type" content="text/html;charset=UTF-8" />
8
+ <title>System down for maintenance</title>
9
+
10
+ <style type="text/css">
11
+ div.outer {
12
+ position: absolute;
13
+ left: 50%;
14
+ top: 50%;
15
+ width: 500px;
16
+ height: 300px;
17
+ margin-left: -260px;
18
+ margin-top: -150px;
19
+ }
20
+
21
+ .DialogBody {
22
+ margin: 0;
23
+ padding: 10px;
24
+ text-align: left;
25
+ border: 1px solid #ccc;
26
+ border-right: 1px solid #999;
27
+ border-bottom: 1px solid #999;
28
+ background-color: #fff;
29
+ }
30
+
31
+ body { background-color: #fff; }
32
+ </style>
33
+ </head>
34
+
35
+ <body>
36
+
37
+ <div class="outer">
38
+ <div class="DialogBody" style="text-align: center;">
39
+ <div style="text-align: center; width: 200px; margin: 0 auto;">
40
+ <p style="color: red; font-size: 16px; line-height: 20px;">
41
+ The system is down for <%= reason ? reason : "maintenance" %>
42
+ as of <%= Time.now.strftime("%H:%M %Z") %>.
43
+ </p>
44
+ <p style="color: #666;">
45
+ It'll be back <%= deadline ? deadline : "shortly" %>.
46
+ </p>
47
+ </div>
48
+ </div>
49
+ </div>
50
+
51
+ </body>
52
+ </html>
metadata ADDED
@@ -0,0 +1,68 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: capcake
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Jad Bitar
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+
12
+ date: 2009-11-16 00:00:00 -05:00
13
+ default_executable:
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: capistrano
17
+ type: :runtime
18
+ version_requirement:
19
+ version_requirements: !ruby/object:Gem::Requirement
20
+ requirements:
21
+ - - ">="
22
+ - !ruby/object:Gem::Version
23
+ version: "2.5"
24
+ version:
25
+ description: Deploy CakePHP applications using Capistrano
26
+ email: jadbitar@mac.com
27
+ executables: []
28
+
29
+ extensions: []
30
+
31
+ extra_rdoc_files:
32
+ - LICENSE
33
+ - README.markdown
34
+ files:
35
+ - lib/capcake.rb
36
+ - lib/templates/maintenance.rhtml
37
+ - LICENSE
38
+ - README.markdown
39
+ has_rdoc: true
40
+ homepage: http://github.com/jadb/capcake
41
+ licenses: []
42
+
43
+ post_install_message:
44
+ rdoc_options:
45
+ - --charset=UTF-8
46
+ require_paths:
47
+ - lib
48
+ required_ruby_version: !ruby/object:Gem::Requirement
49
+ requirements:
50
+ - - ">="
51
+ - !ruby/object:Gem::Version
52
+ version: "0"
53
+ version:
54
+ required_rubygems_version: !ruby/object:Gem::Requirement
55
+ requirements:
56
+ - - ">="
57
+ - !ruby/object:Gem::Version
58
+ version: "0"
59
+ version:
60
+ requirements: []
61
+
62
+ rubyforge_project:
63
+ rubygems_version: 1.3.5
64
+ signing_key:
65
+ specification_version: 3
66
+ summary: Deploy CakePHP applications using Capistrano
67
+ test_files: []
68
+