Brett Walker
2006-Aug-24 09:13 UTC
[Backgroundrb-devel] Unable to start with Capistrano...
I''ve created a couple of tasks in my deploy.rb file for starting and
stopping backgroundrb on the remote server. The stop task runs fine
and kills the process. And the start task *seems* to run successfully,
but backgroundrb is never started on the remote host.
Has anyone had success with this? Here are my deploy tasks:
desc ''Start backgroundrb server (default values)''
task :start_backgroundrb do
puts "Starting BackgrounDRb"
#--- assumes the backgroundrb.yml is set up for production
run "export RAILS_ENV=production &&
#{current_path}/script/backgroundrb/start -d"
end
desc ''Stop backgroundrb server (default values)''
task :stop_backgroundrb do
puts "Stopping BackgrounDRb"
begin
run "#{current_path}/script/backgroundrb/stop"
rescue
end
end
I''m no doubt missing something obvious.
Cheers,
Brett
I''m having the same issue.
My recipe in config/deploy.rb looks like this:
desc "Start backgroundrb"
task :backgroundrb_start, :roles => :app do
run "cd #{current_path} && sudo rake backgroundrb:start
RAILS_ENV=production"
end
(dev machine)
$ cap backgroundrb_start
[ ... command finishes without error ...]
(server)
$ ps auxww | grep backgroundrb
[... nothing ...]
When I run
$ cd /path/to/current && sudo rake backgroundrb:start
RAILS_ENV=production
directly on my server, backgroundrb starts up perfectly, but whenever
run this task remotely, backgroundrb never comes up.
Anyone know what''s going on?
Ezra Zygmuntowicz
2006-Sep-01 15:35 UTC
[Backgroundrb-devel] Unable to start with Capistrano...
On Aug 31, 2006, at 11:40 PM, Eden Li wrote:> I''m having the same issue. > > My recipe in config/deploy.rb looks like this: > > desc "Start backgroundrb" > task :backgroundrb_start, :roles => :app do > run "cd #{current_path} && sudo rake backgroundrb:start > RAILS_ENV=production" > end > > (dev machine) > $ cap backgroundrb_start > [ ... command finishes without error ...] > > (server) > $ ps auxww | grep backgroundrb > [... nothing ...] > > When I run > > $ cd /path/to/current && sudo rake backgroundrb:start > RAILS_ENV=production > > directly on my server, backgroundrb starts up perfectly, but whenever > run this task remotely, backgroundrb never comes up. > > Anyone know what''s going on?It seems that for some reason backgroundrb doesn''t like being started via the rake command to start. So you need to use the actual start script. Here are my tasks for stopping, starting and restarting. desc <<-DESC Stop the backgroundrb server DESC task :stop_backgroundrb , :roles => :drb do run "#{current_path}/script/backgroundrb/stop" end desc <<-DESC Start the backgroundrb server DESC task :start_backgroundrb , :roles => :drb do run "#{current_path}/script/backgroundrb/start -d" end desc <<-DESC Start the backgroundrb server DESC task :restart_backgroundrb , :roles => :app do stop_backgroundrb start_backgroundrb end Cheers- -Ezra
Jonathan Métillon
2006-Sep-01 16:33 UTC
[Backgroundrb-devel] Unable to start with Capistrano...
On 9/1/06, Ezra Zygmuntowicz <ezmobius at gmail.com> wrote:> > Here are my tasks for stopping, starting and restarting. > > desc <<-DESC > Stop the backgroundrb server > DESC > task :stop_backgroundrb , :roles => :drb do > run "#{current_path}/script/backgroundrb/stop" > end > > desc <<-DESC > Start the backgroundrb server > DESC > task :start_backgroundrb , :roles => :drb do > run "#{current_path}/script/backgroundrb/start -d" > end > > desc <<-DESC > Start the backgroundrb server > DESC > task :restart_backgroundrb , :roles => :app do > stop_backgroundrb > start_backgroundrb > end > > > Cheers- > -EzraMaybe this is overkill but here is a bash script I''ve wrote to forcefully restart BackgrounDRb: #!/bin/sh if [ -a "log/backgroundrb.pid" ]; then pid=`cat log/backgroundrb.pid` if [[ -n "$pid" ]]; then echo "Killing current BackgrounDRb server (pid: $pid)" kill -9 $pid fi fi echo "Starting the BackgrounDRb server" cd /var/www/123/current log="/tmp/backgroundrb.`date +%s`" echo "Writing to $log" nohup rake backgroundrb:start > $log 2>&1 cat $log rm -f $log It is derived from a script I found while googling, I don''t remember who it''s from so I can''t give credit. Here''s what I added to my deploy recipe: task :before_restart, :roles => :app do sudo "#{release_path}/script/backgroundrb/restart" end
Brett Walker
2006-Sep-04 17:55 UTC
[Backgroundrb-devel] Unable to start with Capistrano...
I already had it setup like Ezra, and I could *not* get it to work, even after much gnashing of teeth. The task would always look like it was successful, and the pid file would be sitting there, but the process would be gone. Somehow it must have still been attached to the ssh process. Jonathan''s script definitely works. Bummed I need another script, but glad it''s automated now. Cheers, Brett On 9/2/06, Jonathan M?tillon <jmetillon at gmail.com> wrote:> On 9/1/06, Ezra Zygmuntowicz <ezmobius at gmail.com> wrote: > > > > Here are my tasks for stopping, starting and restarting. > > > > desc <<-DESC > > Stop the backgroundrb server > > DESC > > task :stop_backgroundrb , :roles => :drb do > > run "#{current_path}/script/backgroundrb/stop" > > end > > > > desc <<-DESC > > Start the backgroundrb server > > DESC > > task :start_backgroundrb , :roles => :drb do > > run "#{current_path}/script/backgroundrb/start -d" > > end > > > > desc <<-DESC > > Start the backgroundrb server > > DESC > > task :restart_backgroundrb , :roles => :app do > > stop_backgroundrb > > start_backgroundrb > > end > > > > > > Cheers- > > -Ezra > > Maybe this is overkill but here is a bash script I''ve wrote to > forcefully restart BackgrounDRb: > > #!/bin/sh > > if [ -a "log/backgroundrb.pid" ]; then > pid=`cat log/backgroundrb.pid` > if [[ -n "$pid" ]]; then > echo "Killing current BackgrounDRb server (pid: $pid)" > kill -9 $pid > fi > fi > > echo "Starting the BackgrounDRb server" > cd /var/www/123/current > log="/tmp/backgroundrb.`date +%s`" > echo "Writing to $log" > nohup rake backgroundrb:start > $log 2>&1 > cat $log > rm -f $log > > It is derived from a script I found while googling, I don''t remember > who it''s from so I can''t give credit. > > Here''s what I added to my deploy recipe: > > task :before_restart, :roles => :app do > sudo "#{release_path}/script/backgroundrb/restart" > end > _______________________________________________ > Backgroundrb-devel mailing list > Backgroundrb-devel at rubyforge.org > http://rubyforge.org/mailman/listinfo/backgroundrb-devel >
Ah, it appears `nohup'' is the answer. You if you add nohup before the
backgroundrb script invocation in your capistrano recipe, everything
works perfect:
desc "Start backgroundrb"
task :backgroundrb_start, :roles => :app do
run "RAILS_ENV=#{rails_env} nohup
#{current_path}/script/backgroundrb/start -d > /dev/null 2>&1"
end
Thanks for posting the script. Maybe the next release of backgroundrb
could include capistrano recipes for starting/stopping/restarting the
same way mongrel_cluster does?
On 9/2/06, Jonathan M?tillon <jmetillon at gmail.com>
wrote:> Maybe this is overkill but here is a bash script I''ve wrote to
> forcefully restart BackgrounDRb:
>
> #!/bin/sh
>
> if [ -a "log/backgroundrb.pid" ]; then
> pid=`cat log/backgroundrb.pid`
> if [[ -n "$pid" ]]; then
> echo "Killing current BackgrounDRb server (pid: $pid)"
> kill -9 $pid
> fi
> fi
>
> echo "Starting the BackgrounDRb server"
> cd /var/www/123/current
> log="/tmp/backgroundrb.`date +%s`"
> echo "Writing to $log"
> nohup rake backgroundrb:start > $log 2>&1
> cat $log
> rm -f $log
>
> It is derived from a script I found while googling, I don''t
remember
> who it''s from so I can''t give credit.
>
> Here''s what I added to my deploy recipe:
>
> task :before_restart, :roles => :app do
> sudo "#{release_path}/script/backgroundrb/restart"
> end