lib/legion/service.rb in legionio-0.3.1 vs lib/legion/service.rb in legionio-0.3.2

- old
+ new

@@ -33,13 +33,33 @@ require 'legion/data' Legion::Settings.merge_settings(:data, Legion::Data::Settings.default) Legion::Data.setup end - def setup_settings + # noinspection RubyArgCount + def default_paths + [ + '/etc/legionio', + "#{Etc.getpwuid.dir}/legionio", + "#{ENV['home']}/legionio", + '~/legionio', + './settings' + ] + end + + def setup_settings(default_dir = __dir__) require 'legion/settings' - Legion::Logging.debug('Loading Legion::Settings') - Legion::Settings.load(config_dir: './settings') + config_directory = default_dir + + default_paths.each do |path| + next unless Dir.exist? path + + config_directory = path + break + end + + Legion::Logging.info "Using directory #{config_directory} for settings" + Legion::Settings.load(config_dir: config_directory) Legion::Logging.info('Legion::Settings Loaded') end def setup_logging(log_level: 'info', **_opts) require 'legion/logging'