aboutsummaryrefslogtreecommitdiff
path: root/lib/longboat
diff options
context:
space:
mode:
authorNat Lasseter <nat.lasseter@york.ac.uk>2020-03-04 10:38:24 +0000
committerNat Lasseter <nat.lasseter@york.ac.uk>2020-03-04 10:38:24 +0000
commit239829d669857a929cbd68a25dca3bd7c7b91822 (patch)
tree2b784e00fb95f49c148383d9d456530f4d1a6541 /lib/longboat
parent2202611d8fbaed16739cb37b7f51c9c4b8beaced (diff)
Added jobs-path argument
Diffstat (limited to 'lib/longboat')
-rw-r--r--lib/longboat/config.rb3
-rw-r--r--lib/longboat/jobs.rb18
2 files changed, 12 insertions, 9 deletions
diff --git a/lib/longboat/config.rb b/lib/longboat/config.rb
index 8f4907c..3fd1510 100644
--- a/lib/longboat/config.rb
+++ b/lib/longboat/config.rb
@@ -8,7 +8,8 @@ module Longboat
opt :collect_every, "Collection interval", type: Integer, default: 60
# Job data
- opt :metric_prefix, "Prefix for metric names", type: String, default: "longboat_"
+ opt :jobs_path, "Paths to search for jobs", type: String, default: "./lib/jobs", multi: true
+ opt :metric_prefix, "Prefix for metric names", type: String, default: "longboat_"
# Sinatra server
opt :server_bind, "Server listening address", type: String, default: "127.0.0.1:8564"
diff --git a/lib/longboat/jobs.rb b/lib/longboat/jobs.rb
index f0ada5a..5166993 100644
--- a/lib/longboat/jobs.rb
+++ b/lib/longboat/jobs.rb
@@ -4,17 +4,19 @@ module Longboat
@collector = collector
@jobs = []
@config = config
- end
- def load!
- Dir.entries("./lib/jobs/").each do |file|
- next if file =~ /^\./
+ @config[:jobs_path].each do |dir|
+ next unless Dir.exist?(dir)
+
+ Dir.entries(dir).each do |file|
+ next if file =~ /^\./
- reqname = File.basename(file, ".rb")
- cname = reqname.split('_').map(&:capitalize).join
+ reqname = File.basename(file, ".rb")
+ cname = reqname.split('_').map(&:capitalize).join
- require "jobs/#{reqname}"
- @jobs << Kernel.const_get(cname).new(@collector, job_config)
+ require "jobs/#{reqname}"
+ @jobs << Kernel.const_get(cname).new(@collector, job_config)
+ end
end
end