Deploy script fixes
authorWard Vandewege <ward@clinicalfuture.com>
Sun, 6 Jan 2013 02:34:29 +0000 (21:34 -0500)
committerWard Vandewege <ward@clinicalfuture.com>
Sun, 6 Jan 2013 02:34:29 +0000 (21:34 -0500)
Gemfile
Gemfile.lock
config/deploy.rb

diff --git a/Gemfile b/Gemfile
index 663260b5d298ccdfcd0c4d2644e60277c2543388..00f47a9d7a9e2e57f9ae94db731dafc3925d61fd 100644 (file)
--- a/Gemfile
+++ b/Gemfile
@@ -36,3 +36,4 @@ gem 'jquery-rails'
 # To use debugger
 # gem 'ruby-debug'
 
+gem 'rvm-capistrano'
index 8b75881264b30e3eefd15f44a4ce2ad8b5eb04c9..f4ffdc5bcb0ff2f7fe6b4263f28d56edd3949ce0 100644 (file)
@@ -31,6 +31,12 @@ GEM
       multi_json (>= 1.0, < 1.3)
     arel (2.2.3)
     builder (3.0.3)
+    capistrano (2.12.0)
+      highline
+      net-scp (>= 1.0.0)
+      net-sftp (>= 2.0.0)
+      net-ssh (>= 2.0.14)
+      net-ssh-gateway (>= 1.1.0)
     coffee-rails (3.1.1)
       coffee-script (>= 2.2.0)
       railties (~> 3.1.0)
@@ -41,6 +47,7 @@ GEM
     erubis (2.7.0)
     execjs (1.4.0)
       multi_json (~> 1.0)
+    highline (1.6.11)
     hike (1.2.1)
     i18n (0.6.1)
     jquery-rails (2.1.3)
@@ -54,6 +61,13 @@ GEM
       treetop (~> 1.4.8)
     mime-types (1.19)
     multi_json (1.2.0)
+    net-scp (1.0.4)
+      net-ssh (>= 1.99.1)
+    net-sftp (2.0.5)
+      net-ssh (>= 2.0.9)
+    net-ssh (2.3.0)
+    net-ssh-gateway (1.1.0)
+      net-ssh (>= 1.99.1)
     pg (0.13.2)
     polyglot (0.3.3)
     rack (1.3.6)
@@ -83,6 +97,8 @@ GEM
     rake (0.9.2.2)
     rdoc (3.12)
       json (~> 1.4)
+    rvm-capistrano (1.2.7)
+      capistrano (>= 2.0.0)
     sass (3.2.1)
     sass-rails (3.1.6)
       actionpack (~> 3.1.0)
@@ -114,6 +130,7 @@ DEPENDENCIES
   json
   pg
   rails (= 3.1.5)
+  rvm-capistrano
   sass-rails (~> 3.1.5)
   therubyracer
   uglifier (>= 1.0.3)
index d7b248f11d6951cb24c9463a44e501f4f2269344..073d33828482eb2ce814063c2c31164bc4f05695 100644 (file)
@@ -1,6 +1,6 @@
 set :application, "orvos-server"
 set :domain,      "controller.van"
-set :deploy_to,   "/var/www/orvos.clinicalfuture.com"
+set :deploy_to,   "/var/www/9ujm1.orvosapi.com"
 role :web, "controller.van"
 role :app, "controller.van"
 role :db, "controller.van", :primary=>true
@@ -9,6 +9,14 @@ set :repository,  "git@git.clinicalfuture.com:orvos-server.git"
 set :rails_env,   "production"
 set :config_files, ['database.yml']
 set :git_enable_submodules, true
+set :rvm_ruby_string, '1.9.3'
+require "rvm/capistrano"
+default_run_options[:shell] = '/bin/bash --login'
+#default_run_options[:shell] = '/bin/bash'
+
+set :passenger_port, 3000
+#set :passenger_cmd, "#{bundle_cmd} exec passenger"
+set :passenger_cmd, "passenger"
 
 ssh_options[:forward_agent] = true
 ssh_options[:user] = 'root'
@@ -32,6 +40,7 @@ namespace :deploy do
     # 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"
     # This is for the drb server
     run "touch #{current_path}/Gemfile.lock"
     run "chown www-data:www-data #{current_path}/Gemfile.lock"
@@ -47,14 +56,36 @@ namespace :deploy do
   # 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"
+#    # Tell DRB to restart.
+#    #run "/usr/sbin/monit restart mypg_server.rb"
+#  end 
+#  [:start, :stop].each do |t| 
+#    desc "#{t} task is a no-op with mod_rails"
+#    task t, :roles => :app do ; end 
+#  end 
+
+  # 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"
+  end
+
+  task :stop, :roles => :app, :except => { :no_release => true } do
+    run "cd #{current_path} && #{passenger_cmd} stop -p #{passenger_port}"
+  end
+
   task :restart, :roles => :app, :except => { :no_release => true } do
-    # Tell passenger to restart.
-    run "touch #{current_path}/tmp/restart.txt"
-    # Tell DRB to restart.
-    run "/usr/sbin/monit restart mypg_server.rb"
-  end 
-  [:start, :stop].each do |t| 
-    desc "#{t} task is a no-op with mod_rails"
-    task t, :roles => :app do ; end 
-  end 
+    run <<-CMD
+      if [[ -f #{current_path}/tmp/pids/passenger.#{passenger_port}.pid ]]; then
+        cd #{current_path} && #{passenger_cmd} stop -p #{passenger_port};
+      fi
+    CMD
+
+    run "cd #{current_path} && #{passenger_cmd} start -e #{rails_env} -p #{passenger_port} -d"
+  end
+
 end