lib/splash/backends/file.rb in prometheus-splash-0.3.0 vs lib/splash/backends/file.rb in prometheus-splash-0.4.0

- old
+ new

@@ -1,13 +1,18 @@ # coding: utf-8 module Splash module Backends class File include Splash::Config + include Splash::Exiter + include Splash::Helpers + include Splash::Loggers + def initialize(store) @config = get_config[:backends][:stores][store] @path = @config[:path] + ensure_backend end def list(pattern='*') pattern = suffix_trace(pattern) return Dir.glob("#{@path}/#{pattern}").map{|item| ::File.basename(item,".trace") } @@ -32,9 +37,20 @@ end private def suffix_trace(astring) return "#{astring}.trace" + end + + def ensure_backend + unless verify_folder(name: @config[:path], mode: "644", owner: get_config.user_root, group: get_config.group_root).empty? then + get_logger.warn "File Backend folder : #{@config[:path]} is missing" + if make_folder path: @config[:path], mode: "644", owner: get_config.user_root, group: get_config.group_root then + get_logger.ok "File Backend folder : #{@config[:path]} created" + else + splash_exit case: :configuration_error, more: "File backend creation error" + end + end end end end