Guest User

Untitled

a guest
May 17th, 2018
173
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.63 KB | None | 0 0
  1. require 'capistrano/ext/multistage'
  2.  
  3. set :application, "Dixie Stark Home"
  4. set :repository, "git://github.com/Ravenna/Dixie-Stark-Home.git"
  5.  
  6. # If you aren't deploying to /u/apps/#{application} on the target
  7. # servers (which is the default), you can specify the actual location
  8. # via the :deploy_to variable:
  9. # set :deploy_to, "/var/www/#{application}"
  10.  
  11. # If you aren't using Subversion to manage your source code, specify
  12. # your SCM below:
  13. # set :scm, :subversion
  14. set :scm, :git
  15. set :branch, 'master'
  16.  
  17.  
  18. namespace :deploy do
  19.  
  20.  
  21. desc "Create default database file"
  22. task(:database_config, :roles => :app) do
  23. require 'highline/import'
  24. db = {}
  25. db["adapter"] = choose do |menu|
  26. menu.prompt = "Choose adapter:"
  27. menu.default = 'mysql'
  28. menu.choices('mysql', 'sqlite3', 'postgresql')
  29. end
  30.  
  31. db["host"] = ask("Host:"){ |q| q.default = 'localhost' }
  32. db["database"] = ask("Database name:"){ |q| q.default = "#{application}_production" }
  33. db["username"] = ask("Username:"){ |q| q.validate = /[a-z]{1}[\w]+/i }
  34. db["password"] = ask("Password: "){ |q| q.echo = 'x' }
  35.  
  36. File.open('tmp/database.yml','w'){ |f| f.write({"production" => db}.to_yaml) }
  37. transfer :up, 'tmp/database.yml', "#{shared_path}/database.yml"
  38.  
  39. end
  40.  
  41. task :symlink_database_config, :roles => :web do
  42. run "ln -s #{shared_path}/database.yml #{release_path}/config/database.yml"
  43. end
  44.  
  45. task :symlink_vendor, :roles => :web do
  46. run "ln -s #{shared_path}/vendor/gems #{release_path}/vendor"
  47. run "ln -s #{shared_path}/vendor/rails #{release_path}/vendor"
  48. end
  49.  
  50. task :export_gems, :roles => :web do
  51. run_locally "rake gems:unpack"
  52. run_locally "rake rails:freeze:gems"
  53. run "mkdir -p #{shared_path}/vendor"
  54. %w{gems rails}.each do |dir|
  55. if File.directory?("vendor/#{dir}/")
  56. tarball = "#{dir}.tgz"
  57. run_locally "chmod -R +r vendor/#{dir}"
  58. run_locally "tar cvzf tmp/#{tarball} -C vendor #{dir}" if File.directory?("vendor/#{dir}/")
  59. transfer :up, "tmp/#{tarball}", "#{shared_path}/vendor/", :via => :scp if File.exists?("tmp/#{tarball}")
  60. run "cd #{shared_path}/vendor/ && tar xvzf #{shared_path}/vendor/#{tarball} "
  61. run "rm #{shared_path}/vendor/#{tarball}"
  62. end
  63. end
  64. run_locally "rm -fr vendor/rails vendor/gems"
  65. end
  66.  
  67. task :remove_rdiscount_gem, :roles => :web do
  68. run "rm -fr #{shared_path}/vendor/gems/rdiscount*"
  69. end
  70.  
  71.  
  72.  
  73. end
  74.  
  75.  
  76.  
  77. after "deploy:setup", "deploy:database_config"
  78. after "deploy:finalize_update", "deploy:symlink_database_config"
  79. after "deploy:finalize_update", "deploy:symlink_vendor"
  80. # after "deploy:export_gems", "deploy:remove_rdiscount_gem"
Add Comment
Please, Sign In to add comment