lib/config_skeleton.rb in config_skeleton-2.2.1 vs lib/config_skeleton.rb in config_skeleton-2.3.0

- old
+ new

@@ -143,10 +143,11 @@ # method, passing one or more strings containing the full path to files or # directories to watch. # class ConfigSkeleton include ServiceSkeleton + # All ConfigSkeleton-related errors will be subclasses of this. class Error < StandardError; end # If you get this, someone didn't read the documentation. class NotImplementedError < Error; end @@ -162,10 +163,12 @@ @io_write << "." end end def self.inherited(klass) + klass.boolean "#{klass.service_name.upcase}_CONFIG_ONESHOT".to_sym, default: false + klass.gauge :"#{klass.service_name}_config_ok", docstring: "Whether the last config change was accepted by the server" klass.gauge :"#{klass.service_name}_generation_ok", docstring: "Whether the last config generation completed without error" klass.gauge :"#{klass.service_name}_last_generation_timestamp", docstring: "When the last config generation run was made" klass.gauge :"#{klass.service_name}_last_change_timestamp", docstring: "When the config file was last written to" klass.counter :"#{klass.service_name}_reload_total", docstring: "How many times we've asked the server to reload", labels: [:status] @@ -239,9 +242,14 @@ # def run logger.info(logloc) { "Commencing config management" } write_initial_config + + if config.config_oneshot + logger.info(logloc) { "Oneshot run specified - exiting" } + Process.kill("TERM", $PID) + end watch(*self.class.watches) logger.debug(logloc) { "notifier fd is #{notifier.to_io.inspect}" }