Created
February 10, 2012 16:37
-
-
Save stephenmckinney/1790695 to your computer and use it in GitHub Desktop.
Capistrano task to run South migrations and collect static media
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
after "deploy", "deploy:migrate", "deploy:static", "deploy:restart", "custom:git:tag" | |
namespace :deploy do | |
[:stop, :start, :restart, :reload].each do |action| | |
desc "#{action.to_s.capitalize} Apache." | |
task action, :roles => :app do | |
run "sudo /etc/init.d/apache2 #{action.to_s}" | |
end | |
end | |
desc <<-DESC | |
Run South migrations. | |
Runs South migrations after performing a database backup. | |
Usage: | |
Default: | |
'deploy:migrate' runs 'python manage.py migrate --all' | |
One argument: | |
'deploy:migrate args=pages' runs 'python manage.py migrate gsn' | |
Multiple arguments: | |
'deploy:migrate args="gsn pages"' runs 'python manage.py migrate gsn pages' | |
DESC | |
task :migrate, :roles => :db, :only => { :primary => true } do | |
args = ENV['args'] || "--all" | |
db.backup | |
run ". /var/apps/nti_env/bin/activate && python #{current_path}/manage.py migrate --noinput #{args}" | |
end | |
desc <<-DESC | |
Collect static files from apps and other locations. | |
Runs './manage.py collectstatic' on the server after chown'ing several directories | |
DESC | |
task :static do | |
run ". /var/apps/nti_env/bin/activate && python #{current_path}/manage.py collectstatic --noinput" | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment