Sha256: 16bc16a6e8c7f291f5b829fb0277407b36248fab2a8a640062239d00ef70c7c5

Contents?: true

Size: 828 Bytes

Versions: 9

Compression:

Stored size: 828 Bytes

Contents

#
# showing how to use the scheduler
#

require 'time'

require 'openwfe/util/scheduler'
include OpenWFE


def p (msg)
    t = Time.new
    puts "#{t.iso8601} -- #{msg}"
end
    #
    # a small method for displaying the time at the beginning
    # of each output line


scheduler = Scheduler.new
scheduler.start
    #
    # create a scheduler instance and start it

p "started scheduler"

i = 0

scheduler.schedule("1-60 * * * *") do
    p "minute ##{i}"
    i = i + 1
end

scheduler.schedule_in("2m10s") do
    p "after 2 minutes and 10 seconds stopping the scheduler and exiting..."
    scheduler.do_stop
end
    #
    # using a regular "at" job to stop the scheduler after 4 minutes

scheduler.join
    #
    # align the thread of this program to the scheduler thread
    # i.e. exit program only when scheduler terminates

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
openwferu-0.9.10 examples/scheduler_cron_usage.rb
openwferu-0.9.10.653 examples/scheduler_cron_usage.rb
openwferu-0.9.3 examples/scheduler_cron_usage.rb
openwferu-0.9.4 examples/scheduler_cron_usage.rb
openwferu-0.9.5 examples/scheduler_cron_usage.rb
openwferu-0.9.6 examples/scheduler_cron_usage.rb
openwferu-0.9.7 examples/scheduler_cron_usage.rb
openwferu-0.9.8 examples/scheduler_cron_usage.rb
openwferu-0.9.9 examples/scheduler_cron_usage.rb