deploy.rb revision 6b0d500127a7a81b43af4241d97c23bdce341456
0N/Arequire 'bundler/capistrano'
0N/A
0N/A# RVM
0N/A$:.unshift(File.expand_path('./lib', ENV['rvm_path']))
0N/Arequire 'rvm/capistrano'
0N/Aset :rvm_ruby_string, '1.9.3@ontohub'
0N/A
0N/Ahostname = 'ontohub.orgizm.net'
0N/A
0N/Aset :application, 'ontohub'
0N/Aset :scm, :git
0N/Aset :repository, "git@github.com:digineo/#{application}.git"
0N/Aset :deploy_to, "/srv/http/#{hostname}"
0N/A
0N/Aset :user, application
0N/Aset :use_sudo, false
0N/Aset :deploy_via, :remote_cache
0N/A
0N/Arole :app, hostname
0N/Arole :web, hostname
0N/Arole :db, hostname, :primary => true
0N/A
0N/Anamespace :deploy do
0N/A desc "Restart Application"
0N/A task :restart, :roles => :app, :except => { :no_release => true } do
0N/A run "touch #{current_path}/tmp/restart.txt"
0N/A end
0N/Aend
0N/A
0N/Anamespace :resque do
0N/A def rake_command(cmd)
0N/A run "cd #{current_path} && bundle exec rake #{cmd}", :env => { :RAILS_ENV => rails_env }
0N/A end
0N/A
0N/A desc "Stop resque"
0N/A task :stop do
0N/A rake_command 'resque:stop'
0N/A end
0N/Aend
0N/A
0N/A# https://makandracards.com/makandra/1431-resque-+-god-+-capistrano
0N/Anamespace :god do
0N/A def god_is_running
0N/A !capture("#{god_command} status >/dev/null 2>/dev/null || echo 'not running'").start_with?('not running')
0N/A end
0N/A
0N/A def god_command
0N/A "cd #{current_path}; bundle exec god"
0N/A end
0N/A
0N/A desc "Start god"
0N/A task :start do
0N/A run "#{god_command} -c config/god/app.rb", :env => environment = { :RAILS_ENV => rails_env }
0N/A end
0N/A
0N/A desc "Stop god"
0N/A task :stop do
0N/A if god_is_running
0N/A run "#{god_command} terminate"
0N/A end
0N/A end
0N/A
0N/A desc "Test if god is running"
0N/A task :status do
0N/A puts god_is_running ? "God is running" : "God is NOT running"
0N/A end
0N/Aend
0N/A
0N/Abefore "deploy:update", "god:stop"
0N/Abefore "deploy:update", "resque:stop"
0N/Aafter "deploy:update", "god:start"
after :deploy, "deploy:cleanup"