Make the scheduler frequency tunable via ENV.

Akinori MUSHA 10 gadi atpakaļ
vecāks
revīzija
15484db084
4 mainītis faili ar 10 papildinājumiem un 5 dzēšanām
  1. 5 0
      .env.example
  2. 2 2
      bin/schedule.rb
  3. 1 1
      bin/threaded.rb
  4. 2 2
      lib/huginn_scheduler.rb

+ 5 - 0
.env.example

@@ -132,6 +132,11 @@ ENABLE_INSECURE_AGENTS=false
132 132
 # "on the minute") is disallowed to prevent abuse of service.
133 133
 ENABLE_SECOND_PRECISION_SCHEDULE=false
134 134
 
135
+# Specify the scheduler frequency in seconds (default: 0.3).
136
+# Increasing this value will help reduce the use of system resources
137
+# at the expense of time accuracy.
138
+#SCHEDULER_FREQUENCY=0.3
139
+
135 140
 # Use Graphviz for generating diagrams instead of using Google Chart
136 141
 # Tools.  Specify a dot(1) command path built with SVG support
137 142
 # enabled.

+ 2 - 2
bin/schedule.rb

@@ -11,5 +11,5 @@ unless defined?(Rails)
11 11
   exit 1
12 12
 end
13 13
 
14
-scheduler = HuginnScheduler.new
15
-scheduler.run!
14
+scheduler = HuginnScheduler.new(frequency: ENV['SCHEDULER_FREQUENCY'])
15
+scheduler.run!

+ 1 - 1
bin/threaded.rb

@@ -33,7 +33,7 @@ end
33 33
 
34 34
 threads << Thread.new do
35 35
   safely do
36
-    @scheduler = HuginnScheduler.new
36
+    @scheduler = HuginnScheduler.new(frequency: ENV['SCHEDULER_FREQUENCY'])
37 37
     @scheduler.run!
38 38
     puts "Scheduler stopped ..."
39 39
   end

+ 2 - 2
lib/huginn_scheduler.rb

@@ -96,8 +96,8 @@ class HuginnScheduler
96 96
   FAILED_JOBS_TO_KEEP = 100
97 97
   attr_accessor :mutex
98 98
 
99
-  def initialize
100
-    @rufus_scheduler = Rufus::Scheduler.new
99
+  def initialize(options = {})
100
+    @rufus_scheduler = Rufus::Scheduler.new(options)
101 101
     self.mutex = Mutex.new
102 102
   end
103 103