Hi Lee,

On 7/19/07, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
>
> Anyway, the scheduler is great. I ended up putting the instantiation
> and scheduling into a .rb file required from environment.rb, so it
> starts up when the application does.
>
> However, that also makes it start up in script/console. I don't want
> to have two schedulers' tasks stomping on each other when I run the
> server and console at the same time. I could probably use a semaphore
> stashed in memcached or the database or something. Does anyone have
> other ideas?

Maybe something like

---8<---
unless defined? $scheduler
    $scheduler = OpenWFE::Scheduler.new
    $scheduler.start
    #...
end
--->8---

> Is there any way to stop a particular schedule_every task? Or should I
> allocate a scheduler to it and just stop that when I need to?

The methods schedule(), schedule_at() and schedule_every() each
returns a 'jobid' when called.

You can do :

---8<---
jobid = $scheduler.schedule_every("10s") { puts "hello !" }

#... a bit later

$scheduler.unschedule(job_id)
--->8---

I will document that a bit more.


> I did this:
> scheduler.schedule_at(Time.parse('18 July 2007 14:09:00')) { puts
> "Running the AT job" }
> which is very nice. However, it runs at the start of every application
> launch, well past the time specified. I consider this a bug, since I'd
> like to use it to perform a database action once a month without
> having to worry about it repeating with every application restart.

It's true the schedule_at() will trigger task in the past immediately
and not schedule them.

But should we consider that a bug ? It's a bit weird to have absolute
dates in your program. Why don't you use a [cron] schedule() ?

---8<---
$scheduler.schedule("0 23 1 * *") { do_the_database_task() }
    #
    # will trigger this task on the 1st of each month at 23:00
--->8---

For more explanation on the cron configuration type "man 5 crontab" in
your favourite unix box or get there :
http://unixhelp.ed.ac.uk/CGI/man-cgi?crontab+5


Hope this helps, 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