Skip to content

Commit fa9fc1f

Browse files
committed
Remove setParameter on failed config
1 parent 23e8cc8 commit fa9fc1f

File tree

1 file changed

+14
-13
lines changed

1 file changed

+14
-13
lines changed

test/tools/mongo_config.rb

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -303,6 +303,11 @@ class DbServer < Server
303303

304304
def initialize(config)
305305
@config = config
306+
cmd = init_config!
307+
super(cmd, @config[:host], @config[:port])
308+
end
309+
310+
def init_config!
306311
dbpath = @config[:dbpath]
307312
[dbpath, File.dirname(@config[:logpath])].compact.each{|dir| FileUtils.mkdir_p(dir) unless File.directory?(dir) }
308313
command = @config[:command] || 'mongod'
@@ -316,20 +321,11 @@ def initialize(config)
316321
end
317322
end
318323
cmd = [command, arguments].flatten.compact
319-
super(cmd, @config[:host], @config[:port])
320324
end
321325

322326
def start(verifies = DEFAULT_VERIFIES)
323327
super(verifies)
324-
begin
325-
verify(verifies)
326-
rescue Errno::ESRCH
327-
# Hack for 2.2 in case the server could not start because of an
328-
# invalid setParameter option.
329-
config.delete(:setParameter)
330-
super(verifies)
331-
verify(verifies)
332-
end
328+
verify(verifies)
333329
end
334330

335331
def verify(verifies = 600)
@@ -344,8 +340,13 @@ def verify(verifies = 600)
344340
sleep 1
345341
end
346342
end
347-
system "ps -fp #{@pid}; cat #{@config[:logpath]}"
348-
raise Mongo::ConnectionFailure, "DbServer.start verify via connection probe failed - port:#{@port.inspect} @pid:#{@pid.inspect} kill:#{Process.kill(0, @pid).inspect} running?:#{running?.inspect} cmd:#{cmd.inspect}"
343+
if @config.delete(:setParameter)
344+
@cmd = init_config!
345+
start(verifies)
346+
else
347+
system "ps -fp #{@pid}; cat #{@config[:logpath]}"
348+
raise Mongo::ConnectionFailure, "DbServer.start verify via connection probe failed - port:#{@port.inspect} @pid:#{@pid.inspect} kill:#{Process.kill(0, @pid).inspect} running?:#{running?.inspect} cmd:#{cmd.inspect}"
349+
end
349350
end
350351

351352
end
@@ -356,7 +357,7 @@ def initialize(config)
356357
@config = config
357358
@servers = {}
358359
Mongo::Config::CLUSTER_OPT_KEYS.each do |key|
359-
@servers[key] = @config[key].collect{|conf| DbServer.new(conf)} if @config[key]
360+
@servers[key] = @config[key].collect{|conf| p conf; DbServer.new(conf)} if @config[key]
360361
end
361362
end
362363

0 commit comments

Comments
 (0)