PageRenderTime 26ms CodeModel.GetById 22ms RepoModel.GetById 1ms app.codeStats 0ms

/config/deploy.rb

https://bitbucket.org/xinming/knowledge_base
Ruby | 88 lines | 81 code | 4 blank | 3 comment | 2 complexity | b2fd943695edf5ec4fe7676d9d79e6fc MD5 | raw file
  1. $:.unshift(File.expand_path('./lib', ENV['rvm_path']))
  2. require "rvm/capistrano"
  3. require "bundler/capistrano"
  4. require "capistrano_colors"
  5. #Info
  6. set :rails_env, ENV['rails_env'] || ENV['RAILS_ENV'] || "production"
  7. set :ruby_version, "1.9.2-p290"
  8. set :application_name, "knowledge_base"
  9. set :application, "#{application_name}_#{rails_env}"
  10. set :repository, "git@bitbucket.org:xinming/knowledge_base.git"
  11. ##Rvm
  12. set :rvm_ruby_string, "#{ruby_version}@#{application_name}"
  13. set :rvm_type, :user
  14. #Remote User&Pass
  15. set :user, "dgm59"
  16. set :password, "-&'@$_Q4D6v>B7V=3]Xpw"
  17. #Git User&Pass
  18. set :scm, "git"
  19. set :scm_username, "VbaT"
  20. set :scm_passphrase, "159515"
  21. set :branch, "master"
  22. #deploy
  23. set :deploy_to, "/home/dgm59/git/#{application}"
  24. set :deploy_via, :remote_cache
  25. set :use_sudo, false
  26. set :server_ip, "106.187.46.159"
  27. set :ssh_hostname, "knowledge.dev.thisiscolony.com"
  28. set :keep_releases, 2
  29. #Shared
  30. set :shared_assets, "#{deploy_to}/public"
  31. role :web, server_ip # Your HTTP server, Apache/etc
  32. role :app, server_ip # This may be the same as your `Web` server
  33. role :db, server_ip, :primary => true # This is where Rails migrations will run
  34. after 'deploy:setup', 'deploy:create_shared_folder'
  35. after 'deploy:update_code', 'deploy:symlink_shared_folder'
  36. after 'deploy:symlink_shared_folder', 'deploy:cleanup'
  37. namespace :deploy do
  38. desc "Create shared folders when setup"
  39. task :create_shared_folder do
  40. run "mkdir -p #{shared_path}/public/assets"
  41. run "mkdir -p #{shared_path}/db"
  42. run "touch #{shared_path}/db/#{rails_env}.sqlite3"
  43. end
  44. desc "Symlink shared configs and folders on each release."
  45. task :symlink_shared_folder do
  46. run "rm -rf #{release_path}/public/assets && ln -nfs #{shared_path}/public/assets #{release_path}/public/assets"
  47. run "rm #{release_path}/db/#{rails_env}.sqlite3 && ln -nfs #{shared_path}/db/#{rails_env}.sqlite3 #{release_path}/db/#{rails_env}.sqlite3"
  48. end
  49. end
  50. namespace :unicorn do
  51. desc "Start Unicorn"
  52. task :start do
  53. run "cd #{current_path} && bundle exec unicorn_rails -c config/unicorn.rb -E #{rails_env} -D"
  54. end
  55. desc "Stop Unicorn"
  56. task :stop do
  57. run "cd #{current_path} && kill -9 `cat tmp/pids/unicorn.pid`"
  58. end
  59. desc "Restart Unicorn"
  60. task :restart do
  61. run "cd #{current_path} && kill -s USR2 `cat tmp/pids/unicorn.pid`"
  62. end
  63. desc "Get Unicorn PID"
  64. task :pid do
  65. run "cd #{current_path} && cat tmp/pids/unicorn.pid"
  66. end
  67. desc "Read Rails Log"
  68. task :log do
  69. run "cd #{current_path} && tail -f log/#{rails_env}.log" do |channel, stream, data|
  70. puts # for an extra line break before the host name
  71. puts "#{channel[:host]}: #{data}"
  72. break if stream == :err
  73. end
  74. end
  75. end