copy config files and bundle install --local before deploy:assets:precompile
[arvados.git] / config / deploy.rb
index 3033acc750008a82d6d8f2e6f6d92605334a4585..290f5784d793ff35d829c52e5d0dcd4ff88fb683 100644 (file)
@@ -26,8 +26,8 @@ desc "Clean up old releases"
 set :keep_releases, 5
 before("deploy:cleanup") { set :use_sudo, false }
 
-after "deploy:create_symlink", "deploy:copy_files", :roles => :app
-# after "deploy:create_symlink", "deploy:bundle_install", :roles => :app
+before "deploy:assets:precompile", "deploy:copy_files", :roles => :app
+after "deploy:copy_files", "deploy:bundle_install", :roles => :app
 after "deploy:update", "deploy:migrate", :roles => :db
 after :deploy, 'deploy:cleanup', :roles => :app
 
@@ -35,33 +35,33 @@ namespace :deploy do
   desc "Put a few files in place, ensure correct file ownership"
   task :copy_files, :roles => :app,  :except => { :no_release => true } do
     # Copy a few files/make a few symlinks
-    run "cp /home/passenger/orvos-server/database.yml #{current_path}/config/database.yml"
-    run "cp /home/passenger/orvos-server/secret_token.rb #{current_path}/config/initializers/secret_token.rb"
-    run "cp /home/passenger/orvos-server/production.rb #{current_path}/config/environments/production.rb"
+    run "cp /home/passenger/orvos-server/database.yml #{release_path}/config/database.yml"
+    run "cp /home/passenger/orvos-server/secret_token.rb #{release_path}/config/initializers/secret_token.rb"
+    run "cp /home/passenger/orvos-server/production.rb #{release_path}/config/environments/production.rb"
     # Ensure correct ownership of a few files
-    run "chown www-data:www-data #{current_path}/config/environment.rb"
-    run "chown www-data:www-data #{current_path}/config.ru"
-    run "chown www-data:www-data #{current_path}/config/database.yml"
+    run "chown www-data:www-data #{release_path}/config/environment.rb"
+    run "chown www-data:www-data #{release_path}/config.ru"
+    run "chown www-data:www-data #{release_path}/config/database.yml"
     # This is for the drb server
-    run "touch #{current_path}/Gemfile.lock"
-    run "chown www-data:www-data #{current_path}/Gemfile.lock"
+    run "touch #{release_path}/Gemfile.lock"
+    run "chown www-data:www-data #{release_path}/Gemfile.lock"
     # Keep track of the git commit used for this deploy
     # This is used by the lib/add_debug_info.rb middleware, which injects it in the
     # environment.
-    run "cd #{current_path}; /usr/bin/git rev-parse HEAD > #{current_path}/git-commit.version"
+    run "cd #{release_path}; /usr/bin/git rev-parse HEAD > #{release_path}/git-commit.version"
   end
 
   # desc "Install new gems if necessary"
-  task :bundle_install, :roles => :app,  :except => { :no_release => true } do
-  #   run "cd #{current_path} && bundle install --local"
-  end
+  task :bundle_install, :roles => :app,  :except => { :no_release => true } do
+    run "cd #{release_path} && bundle install --local"
+  end
 
   desc "Restarting mod_rails with restart.txt"
 #  task :restart, :roles => :app, :except => { :no_release => true } do
 #    # Tell passenger to restart.
-#    #run "touch #{current_path}/tmp/restart.txt"
-#    run "cd #{current_path}; passenger stop"
-#    run "cd #{current_path}; passenger start -a 127.0.0.1 -p 3000 -d"
+#    #run "touch #{release_path}/tmp/restart.txt"
+#    run "cd #{release_path}; passenger stop"
+#    run "cd #{release_path}; passenger start -a 127.0.0.1 -p 3000 -d"
 #    # Tell DRB to restart.
 #    #run "/usr/sbin/monit restart mypg_server.rb"
 #  end 
@@ -72,21 +72,21 @@ namespace :deploy do
 
   # Use standalone passenger because we also run gps on this box, on a different ruby/passenger version...
   task :start, :roles => :app, :except => { :no_release => true } do
-    run "cd #{current_path} && #{passenger_cmd} start -e #{rails_env} -p #{passenger_port} -d"
+    run "cd #{release_path} && #{passenger_cmd} start -e #{rails_env} -p #{passenger_port} -d"
   end
 
   task :stop, :roles => :app, :except => { :no_release => true } do
-    run "cd #{current_path} && #{passenger_cmd} stop -p #{passenger_port}"
+    run "cd #{release_path} && #{passenger_cmd} stop -p #{passenger_port}"
   end
 
   task :restart, :roles => :app, :except => { :no_release => true } do
     run <<-CMD
-      if [[ -f #{current_path}/tmp/pids/passenger.#{passenger_port}.pid ]]; then
-        cd #{current_path} && #{passenger_cmd} stop -p #{passenger_port};
+      if [[ -f #{release_path}/tmp/pids/passenger.#{passenger_port}.pid ]]; then
+        cd #{release_path} && #{passenger_cmd} stop -p #{passenger_port};
       fi
     CMD
 
-    run "cd #{current_path} && #{passenger_cmd} start -e #{rails_env} -p #{passenger_port} -d"
+    run "cd #{release_path} && #{passenger_cmd} start -e #{rails_env} -p #{passenger_port} -d"
   end
 
 end