Sha256: 798668ab447eaf86c96c0ab3ea5450690c33da7dc0c104a6633059fd38139937
Contents?: true
Size: 1.55 KB
Versions: 1
Compression:
Stored size: 1.55 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 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 before_init(&blk) @options[:before_init] = blk end def after_init(&blk) @options[:after_init] = 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
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
daemonizer-0.1.6 | lib/daemonizer/dsl.rb |