<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=Content-Type content="text/html; charset=iso-8859-1">
<META content="MSHTML 6.00.5730.11" name=GENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=#ffffff>
<DIV><FONT face=Arial size=2>I'm using backgroundrb for session management and
deletion of visitor-entered information when a session is abandoned. The
visitor can either click a button to end their session and remove their data, or
backgroundrb will do it for them after 5 minutes of inactivity.
</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>Everything's working fine, I think. If the
visitor explicitly logs out, then when the worker checks for their record it
won't be there which will trigger logic that says 'you're done. close the
connection and kill yourself'. What makes me a little worried is that I'm
getting what looks like an error message in backgroundrb.log. I've
included it below. I've also included the worker code. </FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>Can anybody tell me how to verify that the worker
is actually closing the connection and then creating suicide? Versus dying
because of this failed find and not closing the connection
correctly?</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>Thanks,</FONT></DIV>
<DIV><FONT face=Arial size=2>Bill</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>----------- log message -----------</FONT></DIV>
<DIV><FONT face=Arial size=2>Couldn't find Emrec with ID=1 -
(ActiveRecord::RecordNotFound)<BR>C:/InstantRails-1.3/ruby/lib/ruby/gems/1.8/gems/activerecord-1.14.2/lib/active_record/base.rb:955:in
`find_one'<BR>C:/InstantRails-1.3/ruby/lib/ruby/gems/1.8/gems/activerecord-1.14.2/lib/active_record/base.rb:941:in
`find_from_ids'<BR>C:/InstantRails-1.3/ruby/lib/ruby/gems/1.8/gems/activerecord-1.14.2/lib/active_record/base.rb:382:in
`find'<BR>./script/backgroundrb/../../config/../lib/workers/session_worker.rb:20:in
`watch_session'<BR>./script/backgroundrb/../../config/../lib/workers/session_worker.rb:12:in
`do_work'<BR>./script/backgroundrb/../../config/../vendor/plugins/backgroundrb/backgroundrb_rails.rb:36:in
`start_process'<BR>./script/backgroundrb/../../config/../vendor/plugins/backgroundrb/backgroundrb_rails.rb:32:in
`start_process'<BR>./script/backgroundrb/../../config/../vendor/plugins/backgroundrb/backgroundrb.rb:57:in
`new_worker'<BR>C:/InstantRails-1.3/ruby/lib/ruby/1.8/thread.rb:135:in
`synchronize'<BR>./script/backgroundrb/../../config/../vendor/plugins/backgroundrb/backgroundrb.rb:49:in
`new_worker'<BR>C:/InstantRails-1.3/ruby/lib/ruby/1.8/drb/drb.rb:1552:in
`perform_without_block'<BR>C:/InstantRails-1.3/ruby/lib/ruby/1.8/drb/drb.rb:1512:in
`perform'<BR>C:/InstantRails-1.3/ruby/lib/ruby/1.8/drb/drb.rb:1586:in
`main_loop'<BR>C:/InstantRails-1.3/ruby/lib/ruby/1.8/drb/drb.rb:1582:in
`main_loop'<BR>C:/InstantRails-1.3/ruby/lib/ruby/1.8/drb/drb.rb:1578:in
`main_loop'<BR>C:/InstantRails-1.3/ruby/lib/ruby/1.8/drb/drb.rb:1427:in
`run'<BR>C:/InstantRails-1.3/ruby/lib/ruby/1.8/drb/drb.rb:1424:in
`run'<BR>C:/InstantRails-1.3/ruby/lib/ruby/1.8/drb/drb.rb:1344:in
`initialize'<BR>C:/InstantRails-1.3/ruby/lib/ruby/1.8/drb/drb.rb:1624:in
`start_service'<BR>script/backgroundrb/start:108<BR></FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>------------ Worker code ----------</FONT></DIV>
<DIV><FONT face=Arial size=2>class SessionWorker <
BackgrounDRb::Rails<BR> <BR> attr_reader
:time_remaining<BR></FONT><FONT face=Arial size=2> <BR> def
do_work(args)<BR> @time_remaining =
args[:initial_setting].to_i<BR> @emrec_id =
args[:emrec_id]<BR> @session_id =
args[:session_id] <BR> @session_rec =
Session.find(:first,<BR>
:conditions => ["sessid = ?", @session_id])
<BR> watch_session(args)<BR>
sleep(2)<BR> clean_up <BR>
end<BR> <BR> def
watch_session(args)<BR> while @time_remaining >
0<BR> sleep(1)<BR>
emrec = Emrec.find(@emrec_id)<BR> if emrec !=
nil<BR> if emrec.timer_suspended ==
'no'<BR> last_activity =
emrec.last_updated_at<BR>
time_remaining_float = (last_activity + args[:initial_setting].to_i) -
Time.now<BR>
@time_remaining =
time_remaining_float.to_i<BR>
end<BR>
else<BR> @time_remaining =
0<BR> end<BR> end<BR>
end<BR> <BR> def clean_up<BR> emrec =
Emrec.find(@emrec_id)<BR> if emrec !=
nil<BR>
emrec.cleanup<BR>
Session.delete(@session_rec.id)<BR> end<BR>
ActiveRecord::Base.connection.disconnect!<BR>
::BackgrounDRb::MiddleMan.instance.delete_worker @_job_key<BR>
end</FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=Arial size=2>end<BR></FONT></DIV></BODY></HTML>