ahh,
finally I fixed it.
Thx John.
I managed to get it working using a 'semaphore' file.
I hoped there was another way of communicating, but I didn't think of
using a file.
Now I hope we will be on one host for a while....otherwise I'll use
memcache.

For others figuring out this problem, this is what I use now:
##########################################
require 'fileutils'
require 'openwfe/util/scheduler'
include OpenWFE

semaphore = RAILS_ROOT + '/tmp/scheduler'
if File.exist?(semaphore)
  logger.warn "scheduler already started"
else
  begin
    logger.warn "starting scheduler #{ Time.now }"

    scheduler = Scheduler.new
    scheduler.start

    scheduler.schedule_every('4h') do
      # do something
    end

    FileUtils.touch(semaphore)

  rescue Exception => ex
    logger.warn ex
  end
end
##########################################

Very simple, but aren't all answers?

Thx again John!



On Jul 25, 4:26 pm, "John Mettraux" <[EMAIL PROTECTED]> wrote:
> On 7/25/07, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
>
>
>
> > Hello,
>
> > I am using the Openwferu scheduler in a Rails application.
> > It is currently being started from environment.rb.
> > I run the application using Mongrel-cluster.
> > Because this uses 3 different processes I get 3 schedulers and 3 x the
> > actions scheduled.
>
> > I don't know much about threads,
> > but is it possible to have only the first mongrel process startup the
> > scheduler?
>
> Hi,
>
> I don't know anything about Mongrel-cluster.
>
> 1). you could dig Mongrel-cluster documentation to see if there is a
> way to communicate between the clustered instances and prevent
> instances other than instance 0 from using the Scheduler.
>
> 2). you could use an empty 'semaphore' file. Each instance would not
> start the scheduler if the file exists else it will immediately create
> (touch) the file and the start the scheduler.
>
> 3). maybe there is a way for your instances to know that they are
> instances in a cluster and maybe there is a way for them to know "yes,
> I'm the first instance", "no, I'm not the first instance" and behave
> accordingly.
>
> 4). avoid all of that but putting the scheduling logic outside of any
> instance, maybe with code started once, alongside the Mongrel-cluster.
>
> I hope this will help, best regards,
>
> --
> John Mettraux   -///-  http://jmettraux.openwfe.org


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"OpenWFEru users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/openwferu-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to