Module: Cron
- Included in:
- DrbDb
- Defined in:
- lib/DrbDB/Cron.rb
Overview
this file is part of manqod manqod is distributed under the CDDL licence the author of manqod is Dobai-Pataky Balint([email protected])
Defined Under Namespace
Classes: CronJob
Instance Attribute Summary collapse
-
#scheduler ⇒ Object
readonly
Returns the value of attribute scheduler.
Instance Method Summary collapse
- #add_cron(cron_id) ⇒ Object
- #remove_cron(cron_id) ⇒ Object
- #reset_cron(cron_id) ⇒ Object
- #start_cron ⇒ Object
- #stop_cron ⇒ Object
Instance Attribute Details
#scheduler ⇒ Object (readonly)
Returns the value of attribute scheduler.
42 43 44 |
# File 'lib/DrbDB/Cron.rb', line 42 def scheduler @scheduler end |
Instance Method Details
#add_cron(cron_id) ⇒ Object
55 56 57 58 59 60 |
# File 'lib/DrbDB/Cron.rb', line 55 def add_cron(cron_id) admin.rows("select * from cronjobs where id='#{cron_id}'").each{|row| edebug("adding cronjob ##{cron_id} for #{moditem(row["moditems_id"].to_i)}") @crons[row["id"].to_i]=CronJob.new(row["id"].to_i,row["cron"],row["moditems_id"].to_i,row["command"],self).register; } end |
#remove_cron(cron_id) ⇒ Object
48 49 50 51 52 53 54 |
# File 'lib/DrbDB/Cron.rb', line 48 def remove_cron(cron_id) edebug("removing cronjob ##{cron_id}") if @crons.has_key?(cron_id) @crons[cron_id].unregister @crons.delete(cron_id) end end |
#reset_cron(cron_id) ⇒ Object
61 62 63 64 |
# File 'lib/DrbDB/Cron.rb', line 61 def reset_cron(cron_id) remove_cron(cron_id) add_cron(cron_id) end |
#start_cron ⇒ Object
34 35 36 37 38 39 40 41 |
# File 'lib/DrbDB/Cron.rb', line 34 def start_cron einfo("starting Cron") @scheduler = Rufus::Scheduler.start_new @crons=Hash.new admin.rows("select * from cronjobs").each{|row| @crons[row["id"].to_i]=CronJob.new(row["id"].to_i,row["cron"],row["moditems_id"].to_i,row["command"],self).register; } end |
#stop_cron ⇒ Object
44 45 46 47 |
# File 'lib/DrbDB/Cron.rb', line 44 def stop_cron einfo("stopping Cron") @scheduler.stop end |