@@ -303,6 +303,11 @@ class DbServer < Server
303
303
304
304
def initialize ( config )
305
305
@config = config
306
+ cmd = init_config!
307
+ super ( cmd , @config [ :host ] , @config [ :port ] )
308
+ end
309
+
310
+ def init_config!
306
311
dbpath = @config [ :dbpath ]
307
312
[ dbpath , File . dirname ( @config [ :logpath ] ) ] . compact . each { |dir | FileUtils . mkdir_p ( dir ) unless File . directory? ( dir ) }
308
313
command = @config [ :command ] || 'mongod'
@@ -316,20 +321,11 @@ def initialize(config)
316
321
end
317
322
end
318
323
cmd = [ command , arguments ] . flatten . compact
319
- super ( cmd , @config [ :host ] , @config [ :port ] )
320
324
end
321
325
322
326
def start ( verifies = DEFAULT_VERIFIES )
323
327
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 )
333
329
end
334
330
335
331
def verify ( verifies = 600 )
@@ -344,8 +340,13 @@ def verify(verifies = 600)
344
340
sleep 1
345
341
end
346
342
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
349
350
end
350
351
351
352
end
@@ -356,7 +357,7 @@ def initialize(config)
356
357
@config = config
357
358
@servers = { }
358
359
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 ]
360
361
end
361
362
end
362
363
0 commit comments