Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

rake deploy:all_interactive

changes to local deploy.rb required on otw1 and otw2
  • Loading branch information...
commit f365e7f033797e5dfefe6c132f66612dddb9540c 1 parent 0801239
@ambtus ambtus authored
View
3  Capfile
@@ -1,3 +1,4 @@
load 'deploy' if respond_to?(:namespace) # cap2 differentiator
Dir['vendor/plugins/*/recipes/*.rb'].each { |plugin| load(plugin) }
-load 'config/deploy'
+
+load 'config/deploy' # remove this line to skip loading any of the default tasks
View
88 config/deploy.example
@@ -1,65 +1,79 @@
-set :user, "myname"
-set :rails_env, "production"
+# takes care of the bundle install tasks
+require 'bundler/capistrano'
+set :application, "otwarchive"
+set :repository, "http://otwarchive.googlecode.com/svn/trunk/"
+set :scm, :subversion
set :deploy_via, :remote_cache
-set :host, "archiveofourown.org"
+
+set :user, "www-data"
set :auth_methods, "publickey"
-set :repository, "http://otwarchive.googlecode.com/svn/trunk/"
-set :deploy_to, "/var/www/otwarchive"
-set :use_sudo, false
-set :keep_releases, 4
+#ssh_options[:verbose] = :debug
+ssh_options[:auth_methods] = %w(publickey)
+ssh_options[:keys] = %w(/home/www-data/.ssh/id_rsa)
-role :app, host
-role :web, host
-role :db, host, :primary => true
+set :rails_env, "production"
-before "deploy:setup", :local
-after "deploy:update_code", "local:update"
+set :host, "localhost"
+set :deploy_to, "/var/www/otwarchive"
+set :use_sudo, false
+set :keep_releases, 4
-after "deploy:symlink", "deploy:update_crontab"
+role :web, host # where start, stop and restart run
+role :app, host # where code checkout runs
+role :db, host, :primary => true # where rails migrations run
-# note that environment should be set to production only if you want email-sending tasks to be run
namespace :deploy do
+ # restart passenger by touching restart.txt
+ task :start do ; end
+ task :stop do ; end
+ task :restart, :roles => :app, :except => { :no_release => true } do
+ run "touch #{File.join(current_path,'tmp','restart.txt')}"
+ end
+
+ # set to production only if you want email-sending tasks to be run
desc "Update the crontab file"
task :update_crontab, :roles => :db do
- run "cd #{current_path} && whenever --update-crontab #{application} --set environment=production"
+ run "cd #{release_path} && whenever --update-crontab #{application} --set environment=production"
end
+
end
namespace :local do
desc "Create placeholders for configuration files"
task :default do
- run "mkdir -p #{shared_path}/config"
- touch "#{shared_path}/config/database.yml"
- touch "#{shared_path}/config/local.yml"
- touch "#{shared_path}/config/s3.yml"
- touch "#{shared_path}/config/sphinx.yml"
- puts "#{shared_path}/config requires manual configuration"
+ run "mkdir -p #{shared_path}/config"
+ run "mkdir -p #{shared_path}/sphinx"
+ run "mkdir -p #{shared_path}/public"
+ touch "#{shared_path}/config/database.yml"
+ touch "#{shared_path}/config/local.yml"
+ touch "#{shared_path}/config/s3.yml"
+ touch "#{shared_path}/config/sphinx.yml"
+ puts "#{shared_path}/ requires manual configuration!!!"
end
- desc "Update version and link to current"
+ desc "Update version and link to current"
task :update do
- run "ln -sf #{shared_path}/config/sphinx.yml #{release_path}/config/sphinx.yml"
- run "ln -sf #{shared_path}/config/s3.yml #{release_path}/config/s3.yml"
- run "ln -sf #{shared_path}/config/local.yml #{release_path}/config/local.yml"
+ run "ln -sf #{shared_path}/config/sphinx.yml #{release_path}/config/sphinx.yml"
+ run "ln -sf #{shared_path}/config/local.yml #{release_path}/config/local.yml"
+ run "ln -sf #{shared_path}/config/s3.yml #{release_path}/config/s3.yml"
run "sed -i '$d' #{shared_path}/config/local.yml"
run "echo -n 'REVISION: ' >> #{shared_path}/config/local.yml"
run "cat #{release_path}/REVISION >> #{shared_path}/config/local.yml"
- run "ln -sf #{shared_path}/config/database.yml #{release_path}/config/database.yml"
+ run "ln -sf #{shared_path}/config/database.yml #{release_path}/config/database.yml"
+ run "ln -sf #{shared_path}/config/production.sphinx.conf #{release_path}/config/production.sphinx.conf"
+ run "ln -sf #{shared_path}/sphinx #{release_path}/db/sphinx"
+ run "ln -sf #{shared_path}/public/robots.txt #{release_path}/public/robots.txt"
+ ### if you are using google webmaster tools
+ run "ln -sf #{shared_path}/public/googleXXXXX.html #{release_path}/public/googleXXXXX.html"
end
end
+before "deploy:setup", :local
+
+after "deploy:update_code", "local:update"
+after "deploy:symlink", "deploy:update_crontab"
+
after "deploy", "deploy:cleanup"
after "deploy:migrations", "deploy:cleanup"
-
-namespace :mod_rails do
- desc "Restart the application altering tmp/restart.txt for mod_rails."
- task :restart, :roles => :app do
- run "touch #{release_path}/tmp/restart.txt"
- end
-end
-
-namespace :deploy do
- %w(start restart).each { |name| task name, :roles => :app do mod_rails.restart end }
-end
View
418 lib/tasks/deploy_tasks.rake
@@ -1,317 +1,217 @@
namespace :deploy do
+
+ # helper methods
+
def ask(message)
print message
STDIN.gets.chomp.strip
end
-
- def remind
- puts "REMINDER: You must also run this task on #{@server.match(/otw1/) ? 'otw2' : 'otw1'}" unless @reminder
+
+ def notice(message)
+ puts "!!!"
+ puts message
+ puts "!!!"
+ end
+
+ def warn
+ notice "The last command failed.
+Don't go further with the deploy until you have fixed the problem!"
+ @no = ask("Do you want to quit? (y/n): ").match(/[nN]o?/)
+ exit unless @no
end
- desc "Check environment"
- task(:check_environment) do
- unless Rails.env.production?
- raise("Your environment is not set to production -- first do: export RAILS_ENV=production")
+ def ok_or_warn(command)
+ sh command do |ok, result|
+ ok or warn
end
end
-
+
+ # set environment
desc "Get server name"
- task(:get_server) do
- unless @server
- @server = %x{hostname}.chomp
- puts "Running on server #{@server}."
+ task(:get_server_name) do
+ unless @server
+ @server = %x{hostname -s}.chomp
+ notice "Running on server #{@server}.
+If you run into errors at any point do not proceed until they are resolved!!
+You must have sudo power or this WILL NOT WORK"
end
end
- # Tasks for managing the process of deploying to test and to beta
- desc "Get reset information: you must have sudo power or this WILL NOT WORK"
- task(:get_reset_info) do
- @backup_file ||= ask("Enter the location of the backup file (possibly /backup/latest.dump): ")
- @revision_number ||= ask("Enter the current revision number of the REAL archive: ")
- @db_password ||= ask("Enter the database password: ")
- end
+ # sub tasks
+ desc "Run tests"
+ task(:run_tests) do
+ notice "Updating testing environment..."
+ # www-data's home has a checked out version of the deploy branch for testing purposed
+ ok_or_warn %q{sudo su - www-data -c "svn update"}
+ ok_or_warn %q{sudo su - www-data -c "bundle install --quiet"}
+ notice "Running migrations on development database"
+ ok_or_warn %q{sudo su - www-data -c "rake db:migrate RAILS_ENV=development"}
+ ok_or_warn %q{sudo su - www-data -c "rake db:test:clone_structure"}
- desc "Shutdown testarchive: you must have sudo or this WILL NOT WORK"
- task(:shutdown_test) do
- puts %x{sudo a2dissite otwarchive}
- puts %x{sudo apache2ctl graceful}
+ notice "Running tests (will take a while!)"
+ ok_or_warn %q{sudo su - www-data -c "rake cucumber"}
end
- desc "Shutdown beta: you must have sudo or this WILL NOT WORK"
- task(:shutdown_beta => :get_server) do
- remind
- puts %x{sudo a2ensite maintenance}
- puts %x{sudo a2dissite otwarchive}
- puts %x{sudo apache2ctl -t}
- @yes = ask("Did the apache configuration check run without errors just now? (y/n): ").match(/[yY](es)?/)
- if @yes
- puts %x{sudo apache2ctl graceful}
- else
- puts "WARNING: Did NOT restart apache. Please don't go further with deploy until the apache configuration check runs without errors."
- end
- end
-
- desc "Restart testarchive: you must have sudo or this WILL NOT WORK"
- task(:restart_test) do
- puts %x{sudo a2ensite otwarchive}
- puts %x{sudo apache2ctl graceful}
- end
-
- desc "Restart beta: you must have sudo or this WILL NOT WORK"
- task(:restart_beta => :get_server) do
- remind
- puts %x{sudo a2ensite otwarchive}
- puts %x{sudo a2dissite maintenance}
- puts %x{sudo apache2ctl -t}
- @yes = ask("Did the apache configuration check run without errors just now? (y/n): ").match(/[yY](es)?/)
- if @yes
- puts %x{sudo apache2ctl graceful}
- else
- puts "WARNING: Did NOT restart apache. Please don't go further with deploy until the apache configuration check runs without errors."
- end
+ desc "Shutdown website"
+ task(:shutdown_website => :get_server_name) do
+
+ ok_or_warn %q{sudo a2ensite maintenance} unless @server == "stage"
+ ok_or_warn %q{sudo a2dissite otwarchive}
+ ok_or_warn %q{sudo apache2ctl -t}
+ ok_or_warn %q{sudo apache2ctl graceful}
end
-
+
desc "Create backup of archive database"
- task(:backup_db => [:get_server]) do
- if @server != "otw2.transformativeworks.org"
- puts "You cannot back up the database except on otw2."
- else
+ task(:backup_db => :get_server_name) do
+ if @server == "otw2"
@db_backup_name ||= ask("Enter the release number to name the db backup -- no spaces! (eg 0.7.3): ")
- puts %x{sudo su - -c "mysqldump -uroot --all-databases --single-transaction --quick --master-data=1 > /backup/otwarchive/deploys/pre.#{@db_backup_name}"}
+ ok_or_warn %Q{sudo su - -c "mysqldump -uroot --all-databases --single-transaction --quick --master-data=1 > /backup/otwarchive/deploys/pre.#{@db_backup_name}"}
+ else
+ notice "Oops. You can only back up the database on otw2."
end
end
- desc "Revert testarchive db"
- task(:revert_db_test => [:check_environment, :get_server]) do
- if @server != "stage.transformativeworks.org"
- puts "You cannot reset the database with a script on beta! Please contact Systems."
+ desc "Reset db"
+ task(:reset_db => :get_server_name) do
+ if @server != "stage"
+ notice "You cannot revert the real database through this script!"
+ notice "Please contact Systems for help."
+ warn
else
- Rake::Task['db:drop'].invoke
- Rake::Task['db:create'].invoke
- @backup_file ||= ask("Enter the location of the backup file (possibly /backup/latest.dump): ")
- @db_password ||= ask("Enter the database password: ")
- puts %x{mysql -uotwarchive -p#{@db_password} otwarchive_production < #{@backup_file}}
+ @backup_file = ask("Enter the location of the backup file (possibly /backup/latest.dump): ")
+ @db_password = ask("Enter the database password: ")
+ @old_rev = ask("Enter the current revision number of the REAL archive: ")
+
+ notice "Resetting the database. This will take a long time..."
+ ok_or_warn %Q{mysql -uotwarchive -p#{@db_password} -e "drop database otwarchive_production"}
+ ok_or_warn %Q{mysql -uotwarchive -p#{@db_password} -e "create database otwarchive_production"}
+ ok_or_warn %Q{mysql -uotwarchive -p#{@db_password} otwarchive_production < #{@backup_file}}
+
+ notice "Deploying code to match database"
+ ok_or_warn %Q{sudo su - www-data -c "cap deploy -s revision=#{@old_rev}"}
end
end
- desc "Revert testarchive code: you must have sudo power or this WILL NOT WORK"
- task(:revert_code_test => :check_environment) do
- @revision_number ||= ask("Enter the revision number you want to revert to: ")
- puts %x{sudo su - www-data -c "cap deploy -s revision=#{@revision_number}"}
+ desc "Deploy code through capistrano"
+ task(:deploy_code) do
+ @new_rev = ask("Enter the revision number of the deploy branch (or hit return for the latest): ")
+ if @new_rev.blank?
+ @new_rev = %x{sudo su - www-data -c "svnversion"}.chomp
+ @new_rev.gsub!(/M/, "")
+ end
+ notice "Deploying to revision #{@new_rev}..."
+ ok_or_warn %Q{sudo su - www-data -c "cap deploy -s revision=#{@new_rev}"}
end
- desc "Reset testarchive completely: you must have sudo power or this WILL NOT WORK"
- task :reset_test => [:get_reset_info, :shutdown_test, :revert_db_test, :revert_code_test, :restart_test]
-
- desc "Update code and install gems: you must have sudo power or this WILL NOT WORK"
- task(:update_code) do
- remind
- puts %x{sudo su - www-data -c "svn update"}
- puts %x{sudo rake gems:install}
- end
-
- desc "Update the development database"
- task(:update_db) do
- puts %x{sudo su - www-data -c "rake db:migrate RAILS_ENV=development"}
- end
-
- desc "Test code: you must have sudo power or this WILL NOT WORK"
- task(:run_tests) do
- remind
- puts "Updating test db..."
- puts %x{sudo su - www-data -c "rake db:test:clone_structure"}
- puts "Running tests (will take a while!)"
- puts %x{sudo su - www-data -c "rake test RAILS_ENV=test"}
- end
-
- desc "Deploy code on testarchive: you must have sudo power or this WILL NOT WORK"
- task(:deploy_code_test) do
- @new_revision = %x{sudo su - www-data -c "svnversion"}
- @new_revision.gsub!(/M/, "")
- puts "Deploying to revision #{@new_revision}..."
- puts %x{sudo su - www-data -c "cap deploy:migrations -s revision=#{@new_revision}"}
- end
-
- desc "Deploy db migrations on otw2: you must have sudo power"
- task(:deploy_migrations_beta => :get_server) do
- if @server != "otw2.transformativeworks.org"
- puts "You can only run this command on otw2!"
+ desc "Run migrations through capistrano"
+ task(:run_migrations => :get_server_name) do
+ if @server == "otw1"
+ notice "Oops. You can only run this command on otw2."
else
- puts %x{sudo su - www-data -c "cap deploy:migrations"}
+ ok_or_warn %q{sudo su - www-data -c "cap deploy:migrate"}
end
end
- desc "Deploy code on beta: you must have sudo power"
- task(:deploy_code_beta => :get_server) do
- unless @server == "otw1.transformativeworks.org"
- puts "You can only run this command on otw1!"
+ desc "Run after tasks"
+ task(:run_after_tasks => :get_server_name) do
+ if @server == "otw1"
+ notice "Oops. You can only run this command on otw2."
else
- @new_revision = %x{sudo su - www-data -c "svnversion"}
- @new_revision.gsub!(/M/, "")
- puts "Deploying to revision #{@new_revision}..."
- puts %x{sudo su - 'www-data' -c "cap deploy"}
+ ok_or_warn %q{sudo su - www-data -c "cd /var/www/otwarchive/current; RAILS_ENV=production rake After"}
end
end
-
- desc "Restart sphinx"
- task(:restart_sphinx => :get_server) do
- remind
- puts %x{sudo su - 'www-data' -c "/usr/local/bin/ts_restart.sh"}
+
+ desc "Restart website"
+ task(:restart_website => :get_server_name) do
+ ok_or_warn %q{sudo a2ensite otwarchive}
+ ok_or_warn %q{sudo a2dissite maintenance} unless @server == 'stage'
+ ok_or_warn %q{sudo apache2ctl -t}
+ ok_or_warn %q{sudo apache2ctl graceful}
end
desc "Rebuild sphinx (slow)"
- task(:rebuild_sphinx => :get_server) do
- remind
- puts %x{sudo su - 'www-data' -c "/usr/local/bin/ts_rebuild.sh"}
- end
-
- desc "Notify testers list that deploy is complete"
- task(:notify_testers) do
- @new_revision = %x{sudo su - www-data -c "svnversion"}
- @new_revision.gsub!(/M/, "")
- puts %x{echo "testarchive deployed to #{@new_revision}" | mail -s "testarchive deployed" otw-coders@transformativeworks.org otw-testers@transformativeworks.org}
- end
-
- desc "Notify testers list that beta deploy is complete"
- task(:notify_testers_beta) do
- @new_revision = %x{sudo su - www-data -c "svnversion"}
- @new_revision.gsub!(/M/, "")
- puts %x{echo "beta archive deployed to #{@new_revision}" | mail -s "beta archive deployed" otw-coders@transformativeworks.org otw-testers@transformativeworks.org}
+ task(:rebuild_sphinx => :get_server_name) do
+ ok_or_warn %q{sudo su - 'www-data' -c "/usr/local/bin/ts_rebuild.sh"}
end
- desc "Run after tasks"
- task(:run_after_tasks) do
- puts %x{sudo su - www-data -c "rake After RAILS_ENV=production"}
+ desc "Restart sphinx"
+ task(:restart_sphinx => :get_server_name) do
+ ok_or_warn %q{sudo su - 'www-data' -c "/usr/local/bin/ts_restart.sh"}
end
- desc "Run after tasks on beta"
- task(:run_after_tasks_beta) do
- unless @server == "otw2.transformativeworks.org"
- puts "You can only run this command on otw2!"
- else
- @yes = ask("Did the migrations deploy run without errors just now? (y/n): ").match(/[yY](es)?/)
- if @yes
- puts %x{sudo su - www-data -c "cd /var/www/otwarchive/current; RAILS_ENV=production rake After"}
- else
- puts "WARNING: Did NOT run After tasks. Please don't go further with deploy until the migration deploy runs without errors."
- end
- end
+ desc "Send email that deploy is complete"
+ task(:send_email) do
+ @new_rev ||= %x{sudo su - www-data -c "svnversion"}
+ @new_rev.gsub!(/M/, "")
+ recipients = ask("Enter the recipients (or hit return for the default): ")
+ recipients ||= "otw-coders@transformativeworks.org otw-testers@transformativeworks.org"
+ subject = (@server == 'stage') ? "testarchive deployed" : "beta archive deployed"
+ ok_or_warn %Q{echo "testarchive deployed to #{@new_rev}" | mail -s "#{subject}" #{recipients}}
end
- desc "Interactive deploy: asks before running each step"
- task :all_interactive_test do
- @reminder = true # don't show the otw1/otw2 reminders
- @yes = ask("Reset testarchive? (y/n): ").match(/[yY](es)?/)
- Rake::Task['deploy:reset_test'].invoke if @yes
-
- @yes = ask("Update code and migrate/install gems? (y/n): ").match(/[yY](es)?/)
- Rake::Task['deploy:update_code'].invoke if @yes
- Rake::Task['deploy:update_db'].invoke if @yes
-
- @yes = ask("Run tests? (y/n): ").match(/[yY](es)?/)
- Rake::Task['deploy:run_tests'].invoke if @yes
-
- @yes = ask("Shut down testarchive? (y/n): ").match(/[yY](es)?/)
- Rake::Task['deploy:shutdown_test'].invoke if @yes
+ # deploy script
+ desc "Interactive deploy"
+ task(:all_interactive => :get_server_name) do
- @yes = ask("Deploy new code? (y/n): ").match(/[yY](es)?/)
- Rake::Task['deploy:deploy_code_test'].invoke if @yes
-
- @yes = ask("Run the After migration tasks? (y/n): ").match(/[yY](es)?/)
- Rake::Task['deploy:run_after_tasks'].invoke if @yes
-
- @yes = ask("Rebuild sphinx (only if indexes in models changed)? (y/n): ").match(/[yY](es)?/)
- Rake::Task['deploy:rebuild_sphinx'].invoke if @yes
-
- @yes = ask("Restart sphinx? (y/n): ").match(/[yY](es)?/)
- Rake::Task['deploy:restart_sphinx'].invoke if @yes
-
- @yes = ask("Restart testarchive? (y/n): ").match(/[yY](es)?/)
- Rake::Task['deploy:restart_test'].invoke if @yes
-
- @yes = ask("Notify testers? (y/n): ").match(/[yY](es)?/)
- Rake::Task['deploy:notify_testers'].invoke if @yes
-
- end
-
- desc "Interactive beta deploy"
- task(:all_interactive_beta => :get_server) do
- puts "NOTE: Remember, if you run into errors at any stage do not proceed until they are resolved!"
-
- if @server == "otw1.transformativeworks.org"
- @reminder = true
- puts "Running on OTW1... (don't forget to also run this on OTW2!)"
- elsif @server == "otw2.transformativeworks.org"
- @reminder = true
- puts "Running on OTW2... (don't forget to also run this on OTW1!)"
+ if @server == "otw1"
+ notice "Running on OTW1... (don't forget to run this in parallel on OTW2!)"
+ elsif @server == "otw2"
+ notice "Running on OTW2... (don't forget to run this in parallel OTW1!)"
end
-
- # update code
- @yes = ask("Update code & gems? (y/n): ").match(/[yY](es)?/)
- Rake::Task['deploy:update_code'].invoke if @yes
-
- if @server == "otw1.transformativeworks.org"
- @yes = ask("Run tests? (y/n): ").match(/[yY](es)?/)
- Rake::Task['deploy:update_db'].invoke if @yes
- Rake::Task['deploy:run_tests'].invoke if @yes
-
- puts "*** continue on both otw1 and otw2 ***"
+
+ # run tests
+ @yes = ask("Run tests here? (y/n): ").match(/[yY](es)?/)
+ if @yes
+ notice "You don't need to also run them on the other server" unless @server == 'stage'
+ Rake::Task['deploy:run_tests'].invoke
+ notice "You should now alert users on the status twitter that the archive is going down." unless @server == "stage"
else
- puts "*** run tests on otw1 before proceeding ****"
+ notice "Wait until the tests have finished running on the other server" unless @server == 'stage'
end
-
- puts "Reminder: you should now alert users on the status twitter that the archive is going down."
- # shutdown runs on both servers
- @yes = ask("Shut down archive? (y/n): ").match(/[yY](es)?/)
- Rake::Task['deploy:shutdown_beta'].invoke if @yes
+ # shut down website
+ @yes = ask("Shut down the website? (y/n): ").match(/[yY](es)?/)
+ Rake::Task['deploy:shutdown_website'].invoke if @yes
- if @server == "otw2.transformativeworks.org"
+ # backup or reset database
+ if @server == "otw2"
@yes = ask("Backup db? (y/n): ").match(/[yY](es)?/)
Rake::Task['deploy:backup_db'].invoke if @yes
-
- @yes = ask("Deploy migrations? (y/n): ").match(/[yY](es)?/)
- Rake::Task['deploy:deploy_migrations_beta'].invoke if @yes
-
- @yes = ask("Run the post-migration After tasks? (y/n): ").match(/[yY](es)?/)
- Rake::Task['deploy:run_after_tasks'].invoke if @yes
-
- else
- puts "*** run the database backup, migration, and After tasks on otw2 before proceeding ***"
- end
-
- if @server == "otw1.transformativeworks.org"
- @yes = ask("Deploy new code? (y/n): ").match(/[yY](es)?/)
- Rake::Task['deploy:deploy_code_beta'].invoke if @yes
-
- puts "*** continue on both otw1 and otw2 ***"
+ elsif @server == 'stage'
+ @yes = ask("Reset testarchive (will take a while)? (y/n): ").match(/[yY](es)?/)
+ Rake::Task['deploy:revert_db'].invoke if @yes
else
- puts "*** deploy new code on otw1 before proceeding ***"
+ notice "Wait until the database has finished backing up on otw2"
end
-
- if @server == "otw1.transformativeworks.org"
- # deploy sphinx
- @yes = ask("Rebuild sphinx (indexes in models changed)? (y/n): ").match(/[yY](es)?/)
- Rake::Task['deploy:rebuild_sphinx'].invoke if @yes
-
- @yes = ask("Restart sphinx? (y/n): ").match(/[yY](es)?/)
- Rake::Task['deploy:restart_sphinx'].invoke if @yes
- end
-
- ask("Restart webserver? (y/n): ").match(/[yY](es)?/)
- Rake::Task['deploy:restart_beta'].invoke if @yes
-
- if @server == "otw1.transformativeworks.org"
- @yes = ask("Notify testers? (y/n): ").match(/[yY](es)?/)
- Rake::Task['deploy:notify_testers_beta'].invoke if @yes
+
+ # deploy code
+ @yes = ask("Deploy new code? (y/n): ").match(/[yY](es)?/)
+ Rake::Task['deploy:deploy_code'].invoke if @yes
+
+ # run migrations
+ @yes = ask("Run migrations? (y/n): ").match(/[yY](es)?/)
+ Rake::Task['deploy:run_migrations'].invoke if @yes
+
+ # run after tasks
+ @yes = ask("Run the After migration tasks? (y/n): ").match(/[yY](es)?/)
+ Rake::Task['deploy:run_after_tasks'].invoke if @yes
+
+ @yes = ask("Restart webserver? (y/n): ").match(/[yY](es)?/)
+ Rake::Task['deploy:restart_website'].invoke if @yes
+
+ unless @server=='otw2'
+ @yes = ask("Rebuild sphinx (only if indexes have changed in the models)? (y/n): ").match(/[yY](es)?/)
+ if @yes
+ Rake::Task['deploy:rebuild_sphinx'].invoke
+ else
+ @yes = ask("Restart sphinx? (y/n): ").match(/[yY](es)?/)
+ Rake::Task['deploy:restart_sphinx'].invoke if @yes
+ end
end
-
+
+ @yes = ask("Send email? (y/n): ").match(/[yY](es)?/)
+ Rake::Task['deploy:send_email'].invoke if @yes
+
end
-
- desc "Silent deploy: runs all tasks in order without checking"
- task :all_test => [:update_code, :update_db, :run_tests, :shutdown_test, :deploy_code_test, :run_after_tasks, :restart_sphinx, :restart_test, :notify_testers]
-
- desc "Fully reset and deploy, silently"
- task :all_with_reset_test => [:reset_test, :all_test]
end
View
4 lib/tasks/migrate_tasks.rake
@@ -7,12 +7,14 @@ namespace :After do
task(:turn_off_deltas => :environment) do
puts "Disabling Thinking Sphinx updates while we migrate..."
ThinkingSphinx.deltas_enabled=false
+ puts %x{script/delayed_job stop}
end
desc "Turn on thinking sphinx deltas"
task(:turn_on_deltas => :environment) do
ThinkingSphinx.deltas_enabled=true
puts "Re-enabled Thinking Sphinx updates"
+ puts %x{script/delayed_job start}
end
# top_level_tasks isn't writable so we need to do this
@@ -159,7 +161,7 @@ namespace :After do
task(:mark_meta_tags_inherited => :environment) do
MetaTagging.find_each do |meta_tagging|
m = meta_tagging.meta_tag
- print "m" ; STDOUT.flush
+ print m.id ; STDOUT.flush
filters = [m] + m.mergers
print "f" ; STDOUT.flush
m.filtered_works.each do |work|
Please sign in to comment.
Something went wrong with that request. Please try again.