I''ve got backgroundrb handling three periodic tasks. For some reason,
each of them is firing twice on each run. From my backgroundrb.log:
Daily stats in production at Sat Nov 04 03:00:41 EST 2006
Daily stats in production at Sat Nov 04 03:00:41 EST 2006
11 expired sessions being deleted at Sat Nov 04 03:03:41 EST 2006
0 expired sessions being deleted at Sat Nov 04 03:03:41 EST 2006
Database backup in production at Sat Nov 04 03:33:41 EST 2006
Database backup in production at Sat Nov 04 03:33:41 EST 2006
You get the idea.
Each of the workers has some variation of the following:
MINUTES_TO_KEEP = 15
repeat_every MINUTES_TO_KEEP.minutes
first_run Time.now
My backgroundrb.yml config file has:
autostart:
1:
job_key: session_cleanup1
class: session_cleanup_worker
2:
job_key: database_backup1
class: database_backup_worker
3:
job_key: log_statistics
class: daily_stats_worker
Does anybody have an idea why this is happening, and what I can do to
stop it?
--Al Evans
--
Posted via http://www.ruby-forum.com/.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---
Al Evans wrote:> Does anybody have an idea why this is happening, and what I can do to > stop it?I didn''t figure out why this was happening, but here''s a workaround in case anybody else runs into the same problem: LOCK_NAME = "#{RAILS_ROOT}/log/whatever.lock" def lock_file return false if File.exists?(LOCK_NAME) f = File.open(LOCK_NAME, "w") f.close true end def clear_lock_file File.delete(LOCK_NAME) end def do_work(args) if lock_file <do whatever you need to do> clear_lock_file end end --Al Evans-- -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
I have a very similar setup and I can confirm behavior. Not sure why the
workers fire twice. Here''s a solution that doesn''t rely upon
files:
@@running=false
def do_work(args)
if not @@running
@@running=true
<do whatever you need to do>
@@running=false
end
end
--
Posted via http://www.ruby-forum.com/.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---
Chris Stump wrote:> I have a very similar setup and I can confirm behavior. Not sure why the > workers fire twice. Here''s a solution that doesn''t rely upon files: > > @@running=false > > def do_work(args) > if not @@running > @@running=true > <do whatever you need to do> > @@running=false > end > endThanks Chris it''s really a very good solution. -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---