ActiveRecord write stops script from responding to SIGTERM

We’ve got a small daemon we run on our servers, which looks something
like this

require File.dirname(FILE) + ‘/…/config/boot’
require File.dirname(FILE) + ‘/…/config/environment’

ActiveRecord::Base.establish_connection

do
m = Message.next_pending
if m
m.do_something
else
sleep 5
end
end

Stuff gets place in this queue through other interactions with our web
application and this guy processes them. This part all works fine.
The problem is when we try and stop the daemon running by sending a
SIGTERM. If the daemon never found any message to process it exits fine,
but if it did then it doesn not respond to the sigterm and we have to
kill -9 it.

After a bit of investigation we found that our process would respond to
SIGTERM properly as long as we had not done any ActiveRecord writes
(reading from the database is fine). However as soon as we do an update
or a create then the process stops responding to the SIGTERMs. It does
however continue to run properly, and will find and process any new
messages

This is running on an x86 linux machine (rails 1.1.2), anmd we’re using
mysql 4.1
I’m rather at a loss to explain this behaviour, anyone have any ideas

Thanks,

Fred

Hi-

On Jul 4, 2006, at 2:28 AM, Frederick C. wrote:

if m
fine,
messages

This is running on an x86 linux machine (rails 1.1.2), anmd we’re
using
mysql 4.1
I’m rather at a loss to explain this behaviour, anyone have any ideas

Thanks,

Fred

Fred-

I'm not entirely sure why your daemon stops responding after a db

write. But you could convert your daemon over to use my BackgrounDRb
plugin[1] which was written for situations exactly like what you are
doing here.

Check it out here:

*Home page: http://backgroundrb.rubyforge.org
*svn repo: svn://rubyforge.org//var/svn/backgroundrb
*Mailing list: http://rubyforge.org/mailman/listinfo/backgroundrb-devel

-Ezra

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