Sha256: df595cd262feaf63ecf10b124ac264fb134c5cf20c03a5438cc21362afaf3e55
Contents?: true
Size: 1.6 KB
Versions: 13
Compression:
Stored size: 1.6 KB
Contents
class Daemonizer::DslError < StandardError; end class Daemonizer::Dsl def self.evaluate(gemfile) builder = new builder.instance_eval(File.read(gemfile.to_s), gemfile.to_s, 1) builder.instance_variable_get("@configs") end def initialize @source = nil @options = {} @pool = :default @configs = {} end def set_option(option, value = nil, &block) @options[:handler_options] ||= {} if value @options[:handler_options][option.to_sym] = Daemonizer::Option.new(option, value) elsif block_given? @options[:handler_options][option.to_sym] = Daemonizer::Option.new(option, block, true) else raise DslError, "you should supply block or value to :set_option" end end def after_fork(&block) set_option :after_fork, block end def not_cow_friendly @options[:cow_friendly] = false end def handler(handler) @options[:handler] = handler end def poll_period(seconds) @options[:poll_period] = seconds.to_i end def log_file(log) @options[:log_file] = log end def workers(num) @options[:workers] = num.to_i end def prepare(&blk) @options[:prepare] = blk end def start(&blk) @options[:start] = blk end def pid_file(pid) @options[:pid_file] = pid end def pool(name, &blk) @pool = name.to_sym options = @options.dup yield @configs[@pool] = Daemonizer::Config.new(@pool, @options) rescue Daemonizer::Config::ConfigError => e puts "* Error in pool \"#{@pool}\": #{e.to_s}. Skipping..." ensure @options = options @pool = nil end end
Version data entries
13 entries across 13 versions & 1 rubygems