From e7bf1008067610b6e81996dfef4f6d2c834df3ed Mon Sep 17 00:00:00 2001 From: Pavel Chipiga Date: Wed, 14 Dec 2011 22:16:00 +0200 Subject: [PATCH] Redo autostart script to start from user. Write doc. Refactor bluepill capistrano recipe. Refs #1 --- bin/autostart.sh | 2 +- doc/README_FOR_APP | 5 +++++ lib/recipes/bluepill.rb | 21 +++++++++++++-------- 3 files changed, 19 insertions(+), 9 deletions(-) diff --git a/bin/autostart.sh b/bin/autostart.sh index 52f0d2647..c65917012 100755 --- a/bin/autostart.sh +++ b/bin/autostart.sh @@ -2,7 +2,7 @@ for f in `ls /srv` do - sudo -u rosa APP_NAME=$f bundle exec bluepill --no-privileged load /srv/$f/current/config/production.pill + su -l rosa -c "cd /srv/$f/current && APP_NAME=$f bundle exec bluepill --no-privileged load /srv/$f/current/config/production.pill" done /srv/rosa_build/current/bin/mount_downloads.sh diff --git a/doc/README_FOR_APP b/doc/README_FOR_APP index 558ca8b4f..fbcff3042 100644 --- a/doc/README_FOR_APP +++ b/doc/README_FOR_APP @@ -1,3 +1,8 @@ === Basic bootstrap * rake db:drop db:setup == + +=== Setup autostart +Add to /etc/rc.d/rc.local following /srv/rosa_build/current/bin/autostart.sh +== + diff --git a/lib/recipes/bluepill.rb b/lib/recipes/bluepill.rb index 1accfb4dd..545c0364e 100644 --- a/lib/recipes/bluepill.rb +++ b/lib/recipes/bluepill.rb @@ -2,20 +2,25 @@ Capistrano::Configuration.instance(:must_exist).load do namespace :bluepill do set(:bluepill_binary) {"APP_NAME=#{fetch :application} bundle exec bluepill --no-privileged"} - desc "Stop processes that bluepill is monitoring and quit bluepill" - task :quit, :roles => [:app], :on_error => :continue do - run "cd #{fetch :current_path} && #{try_sudo} #{bluepill_binary} stop" - run "cd #{fetch :current_path} && #{try_sudo} #{bluepill_binary} quit" - end - desc "Load bluepill configuration and start it" task :start, :roles => [:app] do run "cd #{fetch :current_path} && #{try_sudo} #{bluepill_binary} load config/production.pill" end + desc "Stop processes that bluepill is monitoring" + task :stop, :roles => [:app], :on_error => :continue do + run "cd #{fetch :current_path} && #{try_sudo} #{bluepill_binary} stop" + end + task :restart, :roles => [:app] do - quit - start + # run "cd #{fetch :current_path} && #{try_sudo} #{bluepill_binary} restart #{fetch :application}" + stop; start + end + + desc "Stop processes that bluepill is monitoring and quit bluepill" + task :quit, :roles => [:app] do + # stop + run "cd #{fetch :current_path} && #{try_sudo} #{bluepill_binary} quit" end desc "Prints bluepills monitored processes statuses"