prevent multiple listen statements for the same adapter within one config cycle
This commit is contained in:
parent
495c88ff77
commit
dfe3e6784b
@ -2,6 +2,12 @@ module Apache
|
||||
# Options that aren't specific to a particular purpose go here. Once enough like methods for a
|
||||
# particular purpose exist, break them out into a separate module.
|
||||
module Master
|
||||
class << self
|
||||
def listening_on
|
||||
@listening_on ||= []
|
||||
end
|
||||
end
|
||||
|
||||
# Build a module list.
|
||||
# Wraps around Modules.build
|
||||
def modules(*modules, &block)
|
||||
@ -15,7 +21,14 @@ module Apache
|
||||
# Listen "1.2.3.4:80"
|
||||
# Listen "2.3.4.5:80"
|
||||
def listen(*opt)
|
||||
opt.each { |adapter| self << "Listen #{adapter.quoteize}" }
|
||||
opt.collect(&:quoteize).each do |adapter|
|
||||
if !Apache::Master.listening_on.include?(adapter)
|
||||
self << "Listen #{adapter}"
|
||||
Apache::Master.listening_on << adapter
|
||||
else
|
||||
$stderr.puts "Multiple Listens for #{adapter}".foreground(:red)
|
||||
end
|
||||
end
|
||||
end
|
||||
alias :listen! :listen
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
require 'apache/config'
|
||||
require 'spec_helper'
|
||||
|
||||
describe Apache::Master, "should provide basic helpers for configuration" do
|
||||
let(:apache) { Apache::Config }
|
||||
@ -81,4 +81,16 @@ describe Apache::Master, "should provide basic helpers for configuration" do
|
||||
apache.set_header 'test3' => [ 'test4', "test5=test6" ]
|
||||
apache.to_a.should == [ 'Header set test test2', 'Header set "test3" "test4" test5=test6' ]
|
||||
end
|
||||
|
||||
describe '#listen' do
|
||||
it 'should not allow one to listen twice on the same interface' do
|
||||
apache.listen "one"
|
||||
apache.listen "two"
|
||||
apache.listen "one"
|
||||
|
||||
apache.to_a.should == [ 'Listen "one"', 'Listen "two"' ]
|
||||
|
||||
Apache::Master.listening_on.should == %w{"one" "two"}
|
||||
end
|
||||
end
|
||||
end
|
||||
|
Loading…
Reference in New Issue
Block a user