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