Use Capistrano to Deploy a Django Project


/ Published in: Ruby
Save to your folder(s)



Copy this code and paste it in your HTML
  1. set :application, "example_com"
  2. set :user, "you"
  3. # set :scm_username, user
  4. set :repository, "[email protected]:#{user}/#{application}.git"
  5. set :deploy_to, "/home/#{user}/public_html/#{application}"
  6. set :scm, :git
  7. set :django_location, "/home/#{user}/sources/django/trunk"
  8. set :django_admin_media, "/django/contrib/admin/media"
  9.  
  10. set :domain, "example.com"
  11. role :app, domain
  12. role :web, domain
  13. role :db, domain, :primary => true
  14.  
  15. # If you use a custom SSH port (a good idea):
  16. # ssh_options[:port] = 22
  17.  
  18. # --------
  19. # Commands
  20. # --------
  21. namespace :deploy do
  22.  
  23. desc "Update project from repository"
  24. task :default do
  25. stream "cd #{deploy_to}; git pull"
  26. end
  27.  
  28. desc "Setup a new project"
  29. task :cold do
  30. stream "git clone #{repository} #{deploy_to};"
  31. end
  32.  
  33. end # Deploy
  34.  
  35. desc "Link Admin media to the project static/ folder"
  36. task :admin_media do
  37. stream "ln -s #{django_location}#{django_admin_media} #{deploy_to}/public/static/base_admin"
  38. end
  39. after "deploy:cold", "admin_media"
  40.  
  41. desc "Remove *.pyc files"
  42. task :delpyc do
  43. stream 'cd #{deploy_to};find . -type f -name "*.pyc" -exec rm -fv {} \;'
  44. end
  45. after "deploy", "delpyc"
  46.  
  47. desc "Restart Apache"
  48. task :restart do
  49. sudo "/etc/init.d/apache2 restart"
  50. end
  51. # after "deploy", "restart"
  52.  
  53. desc "Make sure database is in sync with models"
  54. task :syncdb do
  55. stream "#{deploy_to}/manage.py syncdb"
  56. end
  57.  
  58. # ----
  59. # Misc
  60. # ----
  61. desc "Find the location of Python's site-packages folder"
  62. task :site_packages do
  63. stream "python -c 'from distutils.sysconfig import get_python_lib; print get_python_lib()'"
  64. end

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

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.