Guest User

Untitled

a guest
Mar 14th, 2018
128
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.04 KB | None | 0 0
  1. ## some basic tasks
  2. require 'palmtree/recipes/mongrel_cluster'
  3.  
  4. # == RUBY GEMS =================================================================
  5. namespace :ruby_gems do
  6. desc "Updates RubyGems version"
  7. task :update_system do
  8. sudo "gem update --system"
  9. end
  10.  
  11. desc "Install a RubyGem from remote source"
  12. task :install do
  13. puts "USAGE: GEM=gemname cap gems_install" and next unless ENV['GEM']
  14. sudo "gem install #{ENV['GEM']} --no-ri --no-rdoc"
  15. end
  16. end
  17.  
  18.  
  19. # == NGINX =====================================================================
  20. namespace :nginx do
  21. desc "Start Nginx on the app server."
  22. task :start, :roles => :app do
  23. sudo "/etc/init.d/nginx start"
  24. end
  25.  
  26. desc "Restart the Nginx processes on the app server by starting and stopping the cluster."
  27. task :restart , :roles => :app do
  28. sudo "/etc/init.d/nginx restart"
  29. end
  30.  
  31. desc "Stop the Nginx processes on the app server."
  32. task :stop , :roles => :app do
  33. sudo "/etc/init.d/nginx stop"
  34. end
  35. end
  36.  
  37. # == BACKGROUNDRB ==============================================================
  38. namespace :drb do
  39. desc 'Start backgroundrb'
  40. task :start, :roles => :app do
  41. run "#{current_path}/script/backgroundrb start"
  42. end
  43.  
  44. desc 'Stop backgroundrb'
  45. task :stop, :roles => :app do
  46. run "#{current_path}/script/backgroundrb stop"
  47. end
  48.  
  49. desc 'Restart backgroundrb'
  50. task :restart, :roles => :app do
  51. stop
  52. start
  53. end
  54.  
  55. end
  56.  
  57. # == MONGREL ===================================================================
  58. namespace :deploy do
  59. desc "Start mongrel cluster"
  60. task :start, :roles => :app do
  61. run "cd #{current_path} && sudo mongrel_rails cluster::start"
  62. end
  63.  
  64. desc "Stop mongrel cluster"
  65. task :stop, :roles => :app do
  66. run "cd #{current_path} && sudo mongrel_rails cluster::stop"
  67. end
  68.  
  69. desc "Restart mongrel cluster"
  70. task :restart, :roles => :app do
  71. run "cd #{current_path} && sudo mongrel_rails cluster::restart"
  72. end
  73. end
  74.  
  75. # == CONFIG ====================================================================
  76. namespace :init do
  77. namespace :config do
  78. desc "Create database.yml"
  79. task :database do
  80. set :db_host, Capistrano::CLI.ui.ask("database host: ")
  81. set :db_user, Capistrano::CLI.ui.ask("database user: ")
  82. set :db_pass, Capistrano::CLI.password_prompt("database password: ")
  83. database_configuration =<<-EOF
  84. ---
  85.  
  86. production:
  87. adapter: mysql
  88. database: #{application}
  89. host: #{db_host}
  90. username: #{db_user}
  91. password: #{db_pass}
  92. EOF
  93. run "mkdir -p #{shared_path}/config"
  94. put database_configuration, "#{shared_path}/config/database.yml"
  95. end
  96.  
  97.  
  98. desc "Symlink shared configurations to current"
  99. task :localize, :roles => [:app] do
  100. %w[memcached.yml mongrel_cluster.yml gateway.yml amazon_s3.yml amazon_sqs.yml database.yml backgroundrb.yml].each do |f|
  101. run "rm -f #{current_path}/config/#{f}"
  102. run "ln -nsf #{shared_path}/config/#{f} #{current_path}/config/#{f}"
  103. end
  104. end
  105. end
  106. end
Add Comment
Please, Sign In to add comment