Advertisement
Guest User

Deploy.rb

a guest
Dec 23rd, 2012
174
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Rails 1.35 KB | None | 0 0
  1. namespace :deploy do
  2.   %w[start stop restart].each do |command|
  3.     desc "#{command} unicorn server"
  4.     task command, roles: :app, except: {no_release: true} do
  5.       sudo "chmod a+x #{current_path}/config/unicorn_init.sh"
  6.       run "mkdir -p #{current_path}/tmp/sockets && mkdir -p #{current_path}/tmp/pids"
  7.         run "/etc/init.d/unicorn_#{application} #{command}"
  8.     end
  9.   end
  10.  
  11.   task :setup_config, roles: :app do
  12.     sudo "ln -nfs #{current_path}/config/unicorn_init.sh /etc/init.d/unicorn_#{application}"
  13.     run "mkdir -p #{shared_path}/config"
  14.     run "mkdir -p #{shared_path}/tmp/sockets && mkdir -p #{shared_path}/tmp/pids"
  15.     put File.read("config/database.example.yml"), "#{shared_path}/config/database.yml"
  16.     puts "Now edit the config files in #{shared_path}."
  17.   end
  18.   after "deploy:setup", "deploy:setup_config"
  19.  
  20.   task :symlink_config, roles: :app do
  21.     run "ln -nfs #{shared_path}/config/database.yml #{release_path}/config/database.yml"
  22.   end
  23.   after "deploy:finalize_update", "deploy:symlink_config"
  24.  
  25.   desc "Make sure local git is in sync with remote."
  26.   task :check_revision, roles: :web do
  27.     unless `git rev-parse HEAD` == `git rev-parse origin/master`
  28.       puts "WARNING: HEAD is not the same as origin/master"
  29.       puts "Run `git push` to sync changes."
  30.       exit
  31.     end
  32.   end
  33.   before "deploy", "deploy:check_revision"
  34. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement