aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/longboat/config.rb3
-rw-r--r--lib/longboat/jobs.rb18
-rwxr-xr-xlongboat1
3 files changed, 12 insertions, 10 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
diff --git a/longboat b/longboat
index ee7bfa9..2631d45 100755
--- a/longboat
+++ b/longboat
@@ -9,7 +9,6 @@ config = Longboat::Config.parse!
# Start collection
collector = Longboat::Collector.new(config)
jobs = Longboat::Jobs.new(collector, config)
-jobs.load!
t = jobs.collect_every
# Serve metrics on HTTP