PageRenderTime 50ms CodeModel.GetById 24ms RepoModel.GetById 0ms app.codeStats 0ms

/config/deploy.rb

https://bitbucket.org/jklina/fixelpuckers
Ruby | 93 lines | 62 code | 21 blank | 10 comment | 0 complexity | 743d28268f769d8d7a7eff00716c7917 MD5 | raw file
  1. default_run_options[:pty] = true
  2. #default_environment["PATH"] = "/home/jklina/bin:/usr/kerberos/bin:/usr/local/bin:/bin:/usr/bin"
  3. set :rackspace_username, "josh"
  4. set :rackspace_db_type, "mysql"
  5. set :rackspace_db, "pixelfuckers"
  6. set :rackspace_db_username, "pf"
  7. set :database_yml_template, "database.example.yml"
  8. set :application, "fixelpuckers"
  9. set :deploy_to, "/var/www/#{application}"
  10. set :scm, :mercurial
  11. set :repository, "ssh://hg@bitbucket.org/jklina/fixelpuckers/"
  12. set :user, "#{rackspace_username}"
  13. set :use_sudo, false
  14. set :domain, "pixelfuckers.org"
  15. role :app, domain
  16. role :web, domain
  17. role :db, domain, :primary => true
  18. #desc "Symlink public to what rackspace expects the webroot to be"
  19. #task :after_symlink, :roles => :web do
  20. # run "ln -nfs #{release_path}/public /home/#{rackspace_username}/webapps/#{application}/"
  21. #end
  22. task :after_update_code, :roles => :app do
  23. #Makes sure all the images for submissions, etc appear to be in the public folder. They're really symlinks to the Capistrano shared folder though ;)
  24. %w{assets}.each do |share|
  25. run "rm -rf #{release_path}/public/#{share}"
  26. run "mkdir -p #{shared_path}/system/#{share}"
  27. run "ln -nfs #{shared_path}/system/#{share} #{release_path}/public/#{share}"
  28. run "rm -f #{release_path}/config/actionmailer.yml && ln -s #{shared_path}/config/actionmailer.yml #{release_path}/config/actionmailer.yml"
  29. end
  30. end
  31. namespace :deploy do
  32. # Taken from http://jonathan.tron.name/2006/07/15/capistrano-password-prompt-tips
  33. # Thanks Jonathan! :)
  34. desc "Creates the database configuration on the fly"
  35. task :create_database_configuration, :roles => :app do
  36. require "yaml"
  37. set :production_db_password, proc { Capistrano::CLI.password_prompt("Remote production database password: ") }
  38. db_config = YAML::load_file("config/#{database_yml_template}")
  39. db_config.delete('test')
  40. db_config.delete('development')
  41. db_config['production']['adapter'] = "#{rackspace_db_type}"
  42. db_config['production']['database'] = "#{rackspace_db}"
  43. db_config['production']['username'] = "#{rackspace_db_username}"
  44. db_config['production']['password'] = production_db_password
  45. db_config['production']['host'] = "localhost"
  46. put YAML::dump(db_config), "#{release_path}/config/database.yml", :mode => 0664
  47. end
  48. #For the action mailer settings in environment.rb
  49. desc "Generate actionmailer.yml file"
  50. task :generate_actionmailer_yml, :roles=>:app do
  51. password = Capistrano::CLI.ui.ask "Enter your secret mail password:"
  52. template = File.read("config/deploy/actionmailer.yml.erb")
  53. buffer = ERB.new(template).result(binding)
  54. put buffer, "#{shared_path}/config/actionmailer.yml"
  55. end
  56. after "deploy:update_code", "deploy:create_database_configuration"
  57. after "deploy:create_database_configuration", "deploy:generate_actionmailer_yml"
  58. desc "Redefine deploy:start"
  59. task :start, :roles => :app do
  60. invoke_command " /etc/init.d/nginx start", :via => run_method
  61. end
  62. desc "Redefine deploy:restart"
  63. task :restart, :roles => :app do
  64. invoke_command " /etc/init.d/nginx stop", :via => run_method
  65. invoke_command " /etc/init.d/nginx start", :via => run_method
  66. end
  67. desc "Redefine deploy:stop"
  68. task :stop, :roles => :app do
  69. invoke_command " /etc/init.d/nginx stop", :via => run_method
  70. end
  71. end
  72. ###############################