1 set :application, "orvos-server"
2 set :domain, "controller.van"
3 set :deploy_to, "/var/www/9ujm1.orvosapi.com"
4 role :web, "controller.van"
5 role :app, "controller.van"
6 role :db, "controller.van", :primary=>true
8 set :repository, "git@git.clinicalfuture.com:orvos-server.git"
9 set :rails_env, "production"
10 set :config_files, ['database.yml']
11 set :git_enable_submodules, true
12 set :rvm_ruby_string, '1.9.3'
13 require "rvm/capistrano"
15 default_run_options[:shell] = '/bin/bash --login'
16 #default_run_options[:shell] = '/bin/bash'
18 set :passenger_port, 3000
19 #set :passenger_cmd, "#{bundle_cmd} exec passenger"
20 set :passenger_cmd, "passenger"
22 ssh_options[:forward_agent] = true
23 ssh_options[:user] = 'root'
25 desc "Clean up old releases"
27 before("deploy:cleanup") { set :use_sudo, false }
29 before "deploy:assets:precompile", "deploy:copy_files", :roles => :app
30 after "deploy:copy_files", "deploy:bundle_install", :roles => :app
31 after "deploy:update", "deploy:migrate", :roles => :db
32 after :deploy, 'deploy:cleanup', :roles => :app
35 desc "Put a few files in place, ensure correct file ownership"
36 task :copy_files, :roles => :app, :except => { :no_release => true } do
37 # Copy a few files/make a few symlinks
38 run "cp /home/passenger/orvos-server/database.yml #{release_path}/config/database.yml"
39 run "cp /home/passenger/orvos-server/secret_token.rb #{release_path}/config/initializers/secret_token.rb"
40 run "cp /home/passenger/orvos-server/production.rb #{release_path}/config/environments/production.rb"
41 run "cp /home/passenger/orvos-server/omniauth.rb #{release_path}/config/initializers/omniauth.rb"
42 # Ensure correct ownership of a few files
43 run "chown www-data:www-data #{release_path}/config/environment.rb"
44 run "chown www-data:www-data #{release_path}/config.ru"
45 run "chown www-data:www-data #{release_path}/config/database.yml"
46 # This is for the drb server
47 run "touch #{release_path}/Gemfile.lock"
48 run "chown www-data:www-data #{release_path}/Gemfile.lock"
49 # Keep track of the git commit used for this deploy
50 # This is used by the lib/add_debug_info.rb middleware, which injects it in the
52 run "cd #{release_path}; /usr/bin/git rev-parse HEAD > #{release_path}/git-commit.version"
53 # make sure to symlink the vendor bundle. Cf. http://gembundler.com/rationale.html
54 run "cd #{release_path}; ln -s #{shared_path}/vendor_bundle #{release_path}/vendor/bundle"
57 # desc "Install new gems if necessary"
58 task :bundle_install, :roles => :app, :except => { :no_release => true } do
59 run "cd #{release_path} && bundle install --deployment"
62 desc "Restarting mod_rails with restart.txt"
63 # task :restart, :roles => :app, :except => { :no_release => true } do
64 # # Tell passenger to restart.
65 # #run "touch #{release_path}/tmp/restart.txt"
66 # run "cd #{release_path}; passenger stop"
67 # run "cd #{release_path}; passenger start -a 127.0.0.1 -p 3000 -d"
68 # # Tell DRB to restart.
69 # #run "/usr/sbin/monit restart mypg_server.rb"
71 # [:start, :stop].each do |t|
72 # desc "#{t} task is a no-op with mod_rails"
73 # task t, :roles => :app do ; end
76 # Use standalone passenger because we also run gps on this box, on a different ruby/passenger version...
77 task :start, :roles => :app, :except => { :no_release => true } do
78 run "cd #{release_path} && #{passenger_cmd} start -e #{rails_env} -p #{passenger_port} -d"
81 task :stop, :roles => :app, :except => { :no_release => true } do
82 run "cd #{previous_release} && #{passenger_cmd} stop -p #{passenger_port}"
85 task :restart, :roles => :app, :except => { :no_release => true } do
87 if [[ -f #{previous_release}/tmp/pids/passenger.#{passenger_port}.pid ]]; then
88 cd #{previous_release} && #{passenger_cmd} stop -p #{passenger_port};
92 run "cd #{release_path} && #{passenger_cmd} start -e #{rails_env} -p #{passenger_port} -d"
93 run "sv term /etc/service/dispatch_jobs"