2014-01-30 13:21:38 +08:00
|
|
|
module Scheduler::Schedule
|
2014-03-15 01:02:21 +08:00
|
|
|
|
|
|
|
def daily(options=nil)
|
|
|
|
if options
|
|
|
|
@daily = options
|
|
|
|
end
|
|
|
|
@daily
|
|
|
|
end
|
|
|
|
|
2014-01-30 13:21:38 +08:00
|
|
|
def every(duration=nil)
|
2014-02-06 07:14:41 +08:00
|
|
|
if duration
|
|
|
|
@every = duration
|
|
|
|
if manager = Scheduler::Manager.current
|
|
|
|
manager.ensure_schedule!(self)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
@every
|
|
|
|
end
|
|
|
|
|
2015-06-26 11:32:08 +08:00
|
|
|
# schedule job indepndently on each host (looking at hostname)
|
|
|
|
def per_host
|
|
|
|
@per_host = true
|
|
|
|
end
|
|
|
|
|
|
|
|
def is_per_host
|
|
|
|
@per_host
|
|
|
|
end
|
|
|
|
|
2014-02-06 07:14:41 +08:00
|
|
|
def schedule_info
|
|
|
|
manager = Scheduler::Manager.without_runner
|
|
|
|
manager.schedule_info self
|
|
|
|
end
|
|
|
|
|
|
|
|
def scheduled?
|
2014-03-15 01:02:21 +08:00
|
|
|
!!@every || !!@daily
|
2014-01-30 13:21:38 +08:00
|
|
|
end
|
|
|
|
end
|