Created
July 24, 2008 03:58
-
-
Save trey/2039 to your computer and use it in GitHub Desktop.
Capistrano, Ubuntu, Django
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
set :application, "yoursite_com" | |
set :user, "you" | |
set :scm_username, user | |
set :repository, "[email protected]:#{scm_username}/#{application}.git" | |
set :deploy_to, "/home/#{user}/public_html/#{application}" | |
set :scm, :git | |
set :django_location, "/home/#{user}/sources/django/trunk" | |
set :django_admin_media, "/django/contrib/admin/media" | |
set :domain, "example.com" | |
role :app, domain | |
role :web, domain | |
role :db, domain, :primary => true | |
# If you use a custom SSH port (a good idea): | |
# ssh_options[:port] = 22 | |
# -------- | |
# Commands | |
# -------- | |
namespace :deploy do | |
desc "Update project from repository" | |
task :default do | |
stream "cd #{deploy_to}; git pull" | |
end | |
desc "Setup a new project" | |
task :cold do | |
stream "git clone #{repository} #{deploy_to};" | |
end | |
end # Deploy | |
desc "Link Admin media to the project static/ folder" | |
task :admin_media do | |
stream "ln -s #{django_location}#{django_admin_media} #{deploy_to}/public/static/base_admin" | |
end | |
after "deploy:cold", "admin_media" | |
desc "Remove *.pyc files" | |
task :delpyc do | |
stream 'cd #{deploy_to};find . -type f -name "*.pyc" -exec rm -fv {} \;' | |
end | |
after "deploy", "delpyc" | |
desc "Restart Apache" | |
task :restart do | |
sudo "/etc/init.d/apache2 restart" | |
end | |
after "deploy", "restart" | |
# desc "Set SQLite3 permissions for Apache user" | |
# task :sqlite_perms do | |
# sudo "chgrp -R www-data #{deploy_to}/db; chmod -R 775 #{deploy_to}/db" | |
# end | |
desc "Make sure database is in sync with models" | |
task :syncdb do | |
stream "#{deploy_to}/manage.py syncdb" | |
end | |
# desc "Don't use this" | |
# task :wipe_deployment do | |
# stream "rm -rf #{deploy_to}" | |
# end | |
# ---- | |
# Misc | |
# ---- | |
desc "Find the location of Python's site-packages folder" | |
task :site_packages do | |
stream "python -c 'from distutils.sysconfig import get_python_lib; print get_python_lib()'" | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment