Backgroundrb misbehaving again

I have a really strange problem with Backgroundrb. On one of my staging
servers, it is not recognizing the RAILS_ENV variable for some reason.
I have tried everything I could, that is:

a) stopping and starting from the command line by issuing the following

RAILS_ENV=staging script/backgroundrb stop|start

b) script/backgroundrb stop|start -e staging

c) from the Capistrano script, here are the relevant snippets:

namespace :backgroundrb do
desc “Start backgroundrb service”
task :start, :roles => :app do
run “RAILS_ENV=#{rails_env} nohup
#{current_path}/script/backgroundrb start 2>&1 1>/dev/null”

desc "Stop backgroundrb service"
task :stop, :roles => :app do
  # echo at end makes the return code always 0
  run "test -f #{current_path}/log/ &&

#{current_path}/script/backgroundrb stop; echo"

desc "Restart backgroundrb service"
task :restart, :roles => :app do


When I look at the log, it is clear to me that it is picking up the
development environment since the backgroundrb workers are looking for
the development database. See the following snippet from the log:

Started reminders processing at: 2008-10-28 21:40:01
Unknown database ‘isabont_dev’
real_connect' /var/www/apps/isabont/releases/20081028150434/vendor/rails/activerecord/lib/active_record/connection_adapters/mysql_adapter.rb:505:inconnect’
initialize' /var/www/apps/isabont/releases/20081028150434/vendor/rails/activerecord/lib/active_record/connection_adapters/mysql_adapter.rb:88:innew’
mysql_connection' /var/www/apps/isabont/releases/20081028150434/vendor/rails/activerecord/lib/active_record/connection_adapters/abstract/connection_specification.rb:292:insend’
connection=' /var/www/apps/isabont/releases/20081028150434/vendor/rails/activerecord/lib/active_record/connection_adapters/abstract/connection_specification.rb:260:inretrieve_connection’
connection' /var/www/apps/isabont/releases/20081028150434/vendor/rails/activerecord/lib/active_record/base.rb:2693:inquoted_table_name’
construct_finder_sql' /var/www/apps/isabont/releases/20081028150434/vendor/rails/activerecord/lib/active_record/base.rb:1341:infind_every’
find' /var/www/apps/isabont/current/app/models/reminder.rb:84:infind_delinquent’

That ‘isabont_dev’ is my development database. Why is it failing to
pick up the right environment all of sudden? If it had picked up
staging then my database would be isabont_staging since that is how my
database.yml is configured. What is bad is that this used to work fine
on the same server. That is; I have deployed on this server using the
Capistrano deploy.rb many times before. Exactly the same script works
fine on yet another server in another staging environment (for UK).

Seems like Backgroundrb is stuck on not recognizing the RAILS_ENV no
matter how it is passed to it and defaults to development since it is
trying to query the dev database.

Anyone has experienced this kind of inconsistent behavior in

Thanks in advance for your time and apologies for the long post.


Please disregard.
For those who might be interested, the problem was that Backgroundrb had
spawned a rogue linux process on the port that backgroundrb was supposed
to listen on and will not go down when you shut Backgroundrb via normal
commands. I had to find it and then do a kill -9.
After that, it worked fine.
Are there any simpler to debug and more reliable alternatives out there?
I mainly need a cron style functionality to send out scheduled reminders
and download feeds which are also scheduled.

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs