le1t0-capistrano 2.5.18.001 → 2.5.18.002
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +2 -0
- data/CHANGELOG +15 -0
- data/VERSION +1 -1
- data/lib/capistrano/recipes/deploy.rb +79 -88
- metadata +2 -2
data/.gitignore
CHANGED
data/CHANGELOG
CHANGED
@@ -1,3 +1,18 @@
|
|
1
|
+
== 2.5.18.002 / May 18, 2010
|
2
|
+
|
3
|
+
Various fixes and additions:
|
4
|
+
|
5
|
+
* Add database rollback
|
6
|
+
* Fix deploy:migrations such that it works with bundler (having bundler_gems in shared dir)
|
7
|
+
* Modified control tasks for passenger
|
8
|
+
* Modify deploy:cold (only code) and added deploy:cold:migrations + add variable stating whether or not cold deploy is run
|
9
|
+
* Modify upload task so it reloads the app + add revert task and upload/revert tasks for uploading i18n files
|
10
|
+
* Modified deploy:web:disable such that it only copies public/maintenance.html to public/system/maintenance.html
|
11
|
+
|
12
|
+
== 2.5.18.001 / April 19, 2010
|
13
|
+
|
14
|
+
Fixed transfer methods (get, put, etc) not honoring dry-run.
|
15
|
+
|
1
16
|
== 2.5.18 / March 14, 2010
|
2
17
|
|
3
18
|
Small fix for rolling back if a shell scripts exits non-zero; enabled a rollback if git (or other) externals fail during the deploy.
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
2.5.18.
|
1
|
+
2.5.18.002
|
@@ -23,6 +23,7 @@ _cset(:repository) { abort "Please specify the repository that houses your appl
|
|
23
23
|
|
24
24
|
_cset :scm, :subversion
|
25
25
|
_cset :deploy_via, :checkout
|
26
|
+
_cset :running_cold_deploy, false
|
26
27
|
|
27
28
|
_cset(:deploy_to) { "/u/apps/#{application}" }
|
28
29
|
_cset(:revision) { source.head }
|
@@ -68,6 +69,9 @@ _cset(:run_method) { fetch(:use_sudo, true) ? :sudo : :run }
|
|
68
69
|
# standalone case, or during deployment.
|
69
70
|
_cset(:latest_release) { exists?(:deploy_timestamped) ? release_path : current_release }
|
70
71
|
|
72
|
+
# set i18n languages used by your rails app, comma separated
|
73
|
+
_cset :rails_languages, "en"
|
74
|
+
|
71
75
|
# =========================================================================
|
72
76
|
# These are helper methods that will be available to your recipes.
|
73
77
|
# =========================================================================
|
@@ -291,29 +295,25 @@ namespace :deploy do
|
|
291
295
|
abort "Please specify at least one file or directory to update (via the FILES environment variable)" if files.empty?
|
292
296
|
|
293
297
|
files.each { |file| top.upload(file, File.join(current_path, file)) }
|
298
|
+
top.deploy.restart unless (ENV['NO_RESTART'] || "").downcase == 'true'
|
294
299
|
end
|
295
300
|
|
296
|
-
desc
|
297
|
-
Restarts your application. This works by calling the script/process/reaper \
|
298
|
-
script under the current path.
|
299
|
-
|
300
|
-
If you are deploying a Rails 2.3.x application, you will need to install
|
301
|
-
these http://github.com/rails/irs_process_scripts (more info about why
|
302
|
-
on that page.)
|
303
|
-
|
304
|
-
By default, this will be invoked via sudo as the `app' user. If \
|
305
|
-
you wish to run it as a different user, set the :runner variable to \
|
306
|
-
that user. If you are in an environment where you can't use sudo, set \
|
307
|
-
the :use_sudo variable to false:
|
308
|
-
|
309
|
-
set :use_sudo, false
|
310
|
-
DESC
|
301
|
+
desc "Restarts your application."
|
311
302
|
task :restart, :roles => :app, :except => { :no_release => true } do
|
312
|
-
|
313
|
-
try_runner "#{current_path}/script/process/reaper"
|
303
|
+
run "touch #{current_path}/tmp/restart.txt"
|
314
304
|
end
|
315
305
|
|
316
306
|
namespace :rollback do
|
307
|
+
before 'deploy:rollback:revision', 'deploy:rollback:db'
|
308
|
+
desc "Rolls back database to migration level of the previously deployed release"
|
309
|
+
task :db, :roles => :db, :only => { :primary => true } do
|
310
|
+
if previous_release
|
311
|
+
run "cd #{current_path}; rake RAILS_ENV=#{rails_env} db:migrate VERSION=`cd #{File.join(previous_release, 'db', 'migrate')} && ls -1 [0-9]*_*.rb | sort | tail -1 | sed -e s/_.*$//`"
|
312
|
+
else
|
313
|
+
abort "could not rollback the db because there is no prior release"
|
314
|
+
end
|
315
|
+
end
|
316
|
+
|
317
317
|
desc <<-DESC
|
318
318
|
[internal] Points the current symlink at the previous revision.
|
319
319
|
This is called by the rollback sequence, and should rarely (if
|
@@ -398,10 +398,11 @@ namespace :deploy do
|
|
398
398
|
because migrations are not guaranteed to be reversible.
|
399
399
|
DESC
|
400
400
|
task :migrations do
|
401
|
-
|
401
|
+
# when using bundler, symlink has to run before migrate (unless you want to fully rebundle each deployment)
|
402
|
+
set :migrate_target, :current
|
402
403
|
update_code
|
403
|
-
migrate
|
404
404
|
symlink
|
405
|
+
migrate
|
405
406
|
restart
|
406
407
|
end
|
407
408
|
|
@@ -465,51 +466,34 @@ namespace :deploy do
|
|
465
466
|
end
|
466
467
|
end
|
467
468
|
|
468
|
-
|
469
|
-
|
470
|
-
|
471
|
-
|
472
|
-
|
473
|
-
|
474
|
-
|
475
|
-
|
476
|
-
|
477
|
-
|
478
|
-
|
469
|
+
namespace :cold do
|
470
|
+
|
471
|
+
desc <<-DESC
|
472
|
+
Deploys a `cold' application. It will deploy the code.
|
473
|
+
DESC
|
474
|
+
task :default do
|
475
|
+
set :running_cold_deploy, true
|
476
|
+
update
|
477
|
+
end
|
478
|
+
|
479
|
+
desc <<-DESC
|
480
|
+
Deploys a `cold' application. It will deploy the code and run any \
|
481
|
+
pending migrations.
|
482
|
+
DESC
|
483
|
+
task :migrations do
|
484
|
+
set :running_cold_deploy, true
|
485
|
+
update
|
486
|
+
migrate
|
487
|
+
end
|
488
|
+
|
479
489
|
end
|
480
490
|
|
481
|
-
desc
|
482
|
-
Start the application servers. This will attempt to invoke a script \
|
483
|
-
in your application called `script/spin', which must know how to start \
|
484
|
-
your application listeners. For Rails applications, you might just have \
|
485
|
-
that script invoke `script/process/spawner' with the appropriate \
|
486
|
-
arguments.
|
487
|
-
|
488
|
-
By default, the script will be executed via sudo as the `app' user. If \
|
489
|
-
you wish to run it as a different user, set the :runner variable to \
|
490
|
-
that user. If you are in an environment where you can't use sudo, set \
|
491
|
-
the :use_sudo variable to false.
|
492
|
-
DESC
|
491
|
+
desc "This does nothing, but is here for backwards compatibility."
|
493
492
|
task :start, :roles => :app do
|
494
|
-
warn "[DEPRECATED] `deploy:start` is going to be removed after 2.5.9 - see http://is.gd/2BPeA"
|
495
|
-
run "cd #{current_path} && #{try_runner} nohup script/spin"
|
496
493
|
end
|
497
494
|
|
498
|
-
desc
|
499
|
-
Stop the application servers. This will call script/process/reaper for \
|
500
|
-
both the spawner process, and all of the application processes it has \
|
501
|
-
spawned. As such, it is fairly Rails specific and may need to be \
|
502
|
-
overridden for other systems.
|
503
|
-
|
504
|
-
By default, the script will be executed via sudo as the `app' user. If \
|
505
|
-
you wish to run it as a different user, set the :runner variable to \
|
506
|
-
that user. If you are in an environment where you can't use sudo, set \
|
507
|
-
the :use_sudo variable to false.
|
508
|
-
DESC
|
495
|
+
desc "This does nothing, but is here for backwards compatibility."
|
509
496
|
task :stop, :roles => :app do
|
510
|
-
warn "[DEPRECATED] `deploy:start` is going to be removed after 2.5.9 - see http://is.gd/2BPeA"
|
511
|
-
run "if [ -f #{current_path}/tmp/pids/dispatch.spawner.pid ]; then #{try_runner} #{current_path}/script/process/reaper -a kill -r dispatch.spawner.pid; fi"
|
512
|
-
try_runner "#{current_path}/script/process/reaper -a kill"
|
513
497
|
end
|
514
498
|
|
515
499
|
namespace :pending do
|
@@ -540,40 +524,16 @@ namespace :deploy do
|
|
540
524
|
servers must be configured to detect the presence of this file, and if \
|
541
525
|
it is present, always display it instead of performing the request.
|
542
526
|
|
543
|
-
|
544
|
-
|
545
|
-
|
546
|
-
|
547
|
-
$ cap deploy:web:disable \\
|
548
|
-
REASON="hardware upgrade" \\
|
549
|
-
UNTIL="12pm Central Time"
|
550
|
-
|
551
|
-
Further customization will require that you write your own task.
|
527
|
+
This just copies public/maintenance.html to public/system/maintenance.html.
|
528
|
+
Use a before hook to generate/initialize the public/maintenance.html if you
|
529
|
+
want it to contain dynamic information.
|
552
530
|
DESC
|
553
531
|
task :disable, :roles => :web, :except => { :no_release => true } do
|
554
532
|
require 'erb'
|
555
|
-
on_rollback { run "rm #{shared_path}/system/maintenance.html" }
|
533
|
+
on_rollback { run "rm -f #{shared_path}/system/maintenance.html" }
|
556
534
|
|
557
|
-
|
558
|
-
|
559
|
-
# Please add something like this to your site's htaccess to redirect users to the maintenance page.
|
560
|
-
# More Info: http://www.shiftcommathree.com/articles/make-your-rails-maintenance-page-respond-with-a-503
|
561
|
-
|
562
|
-
ErrorDocument 503 /system/maintenance.html
|
563
|
-
RewriteEngine On
|
564
|
-
RewriteCond %{REQUEST_URI} !\.(css|gif|jpg|png)$
|
565
|
-
RewriteCond %{DOCUMENT_ROOT}/system/maintenance.html -f
|
566
|
-
RewriteCond %{SCRIPT_FILENAME} !maintenance.html
|
567
|
-
RewriteRule ^.*$ - [redirect=503,last]
|
568
|
-
EOHTACCESS
|
569
|
-
|
570
|
-
reason = ENV['REASON']
|
571
|
-
deadline = ENV['UNTIL']
|
572
|
-
|
573
|
-
template = File.read(File.join(File.dirname(__FILE__), "templates", "maintenance.rhtml"))
|
574
|
-
result = ERB.new(template).result(binding)
|
575
|
-
|
576
|
-
put result, "#{shared_path}/system/maintenance.html", :mode => 0644
|
535
|
+
run "cp #{current_path}/public/maintenance.html #{current_path}/public/system/maintenance.html"
|
536
|
+
run "chmod 644 #{current_path}/public/system/maintenance.html"
|
577
537
|
end
|
578
538
|
|
579
539
|
desc <<-DESC
|
@@ -586,4 +546,35 @@ namespace :deploy do
|
|
586
546
|
run "rm #{shared_path}/system/maintenance.html"
|
587
547
|
end
|
588
548
|
end
|
549
|
+
|
550
|
+
namespace :hack do
|
551
|
+
desc "upload ymls to server from local checked out branch, CAUTION: can break the server!"
|
552
|
+
task :upload_ymls do
|
553
|
+
(ENV["LANGUAGES"] || rails_languages).split(',').each do |lang|
|
554
|
+
if File.exists?("config/locales/#{lang}.yml")
|
555
|
+
buffer = File.read("config/locales/#{lang}.yml")
|
556
|
+
put buffer, "#{current_path}/config/locales/#{lang}.yml", :mode => 0644
|
557
|
+
end
|
558
|
+
end
|
559
|
+
top.deploy.restart unless (ENV['NO_RESTART'] || "").downcase == 'true'
|
560
|
+
end
|
561
|
+
|
562
|
+
desc "revert changed ymls on server, not to be used on test!"
|
563
|
+
task :revert_ymls do
|
564
|
+
(ENV["LANGUAGES"] || rails_languages).split(',').each do |lang|
|
565
|
+
run "cd #{current_path}/config/locales/ ; git checkout #{lang}.yml"
|
566
|
+
end
|
567
|
+
top.deploy.restart unless (ENV['NO_RESTART'] || "").downcase == 'true'
|
568
|
+
end
|
569
|
+
|
570
|
+
desc "revert uploaded/changed files on server"
|
571
|
+
task :revert do
|
572
|
+
abort "You have to specify the files to revert in env var FILES (comma separated)" unless ENV['FILES']
|
573
|
+
|
574
|
+
ENV['FILES'].split(',').each do |file|
|
575
|
+
run "cd #{current_path} ; git checkout #{file}"
|
576
|
+
end
|
577
|
+
top.deploy.restart unless (ENV['NO_RESTART'] || "").downcase == 'true'
|
578
|
+
end
|
579
|
+
end
|
589
580
|
end
|