apache-config-generator/lib/apache/mpm_prefork.rb

60 lines
1.3 KiB
Ruby
Raw Normal View History

2010-05-05 16:25:07 +00:00
module Apache
module MPM
2010-05-07 20:04:06 +00:00
# Set up the Prefork MPM
#
2010-05-10 19:57:34 +00:00
# prefork_config do
# start 5
# spares 5, 20
# limit 100
# clients 100
# max_requests 1000
# end
#
# becomes:
#
# StartServers 5
# MinSpareServers 5
# MaxSpareServers 20
# ServerLimit 100
# MaxClients 100
# MaxRequestsPerChild 1000
#
2010-05-07 20:04:06 +00:00
def prefork_config(&block)
self + Apache::MPM::Prefork.build(&block)
end
2010-05-10 19:57:34 +00:00
# Builder for Prefork MPM
# See Apache::MPM::prefork_config for usage.
2010-05-05 16:25:07 +00:00
class Prefork
class << self
def build(&block)
@config = ['', '# Prefork config', '']
self.instance_eval(&block)
@config
end
def method_missing(method, *opts)
if which = {
:start => 'StartServers',
:spares => [ 'MinSpareServers', 'MaxSpareServers' ],
:limit => 'ServerLimit',
:clients => 'MaxClients',
:max_requests => 'MaxRequestsPerChild'
}[method]
case which
when String
@config << "#{which} #{opts * " "}"
when Array
which.each do |w|
@config << "#{w} #{opts.shift}"
end
end
end
end
end
end
end
end