Return to Snippet

Revision: 11479
at February 6, 2009 15:14 by trey


Initial Code
set :application, "example_com"
set :user, "you"
# set :scm_username, user
set :repository,  "[email protected]:#{user}/#{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 "Make sure database is in sync with models"
task :syncdb do
  stream "#{deploy_to}/manage.py syncdb"
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

Initial URL
http://gist.github.com/2039

Initial Description

                                

Initial Title
Use Capistrano to Deploy a Django Project

Initial Tags
django

Initial Language
Ruby