@@ -82,8 +82,8 @@ def start
82
82
83
83
private def do_start
84
84
config [ :db_dirs ] . each do |db_dir |
85
- cmd = config [ :settings ] [ db_dir ] [ :start_cmd ]
86
- Helper . spawn_mongo ( *cmd )
85
+ opts = config [ :settings ] [ db_dir ] [ :start_options ]
86
+ Helper . spawn_mongo ( ** opts )
87
87
end
88
88
end
89
89
@@ -97,7 +97,8 @@ def stop
97
97
pids = { }
98
98
99
99
config [ :db_dirs ] . reverse . each do |db_dir |
100
- binary_basename = File . basename ( config [ :settings ] [ db_dir ] [ :start_cmd ] . first )
100
+ binary_path = config [ :settings ] [ db_dir ] [ :start_options ] [ :bin_path ]
101
+ binary_basename = File . basename ( binary_path )
101
102
pid_file_path = File . join ( db_dir , "#{ binary_basename } .pid" )
102
103
if File . exist? ( pid_file_path )
103
104
pid = File . read ( pid_file_path ) . strip . to_i
@@ -130,7 +131,8 @@ def stop
130
131
private
131
132
132
133
def do_wait ( db_dir , pid )
133
- binary_basename = File . basename ( config [ :settings ] [ db_dir ] [ :start_cmd ] . first )
134
+ binary_path = config [ :settings ] [ db_dir ] [ :start_options ] [ :bin_path ]
135
+ binary_basename = File . basename ( binary_path )
134
136
Helper . wait_for_pid ( db_dir , pid , 15 , binary_basename )
135
137
end
136
138
@@ -321,16 +323,18 @@ def init_sharded
321
323
dir = root_dir . join ( "router%02d-#{ port } " % mongos )
322
324
puts ( "Spawn mongos on port #{ port } " )
323
325
FileUtils . mkdir ( dir )
324
- cmd = [
325
- mongo_path ( 'mongos' ) ,
326
- dir . join ( 'mongos.log' ) . to_s ,
327
- dir . join ( 'mongos.pid' ) . to_s ,
328
- '--port' , port . to_s ,
329
- '--configdb' , config_db_opt ,
330
- ] + server_tls_args + common_args +
331
- passthrough_args + ( options [ :mongos_passthrough_args ] || [ ] )
332
- Helper . spawn_mongo ( *cmd )
333
- record_start_command ( dir , cmd )
326
+ opts = {
327
+ bin_path : mongo_path ( 'mongos' ) ,
328
+ log_path : dir . join ( 'mongos.log' ) . to_s ,
329
+ pid_file_path : dir . join ( 'mongos.pid' ) . to_s ,
330
+ args : [
331
+ '--port' , port . to_s ,
332
+ '--configdb' , config_db_opt ,
333
+ ] + server_tls_args + common_args +
334
+ passthrough_args + ( options [ :mongos_passthrough_args ] || [ ] ) ,
335
+ }
336
+ Helper . spawn_mongo ( **opts )
337
+ record_start_command ( dir , opts )
334
338
end
335
339
336
340
write_config
@@ -582,37 +586,41 @@ def client_tls_options
582
586
def spawn_standalone ( dir , port , args )
583
587
puts ( "Spawn mongod on port #{ port } " )
584
588
FileUtils . mkdir_p ( dir )
585
- cmd = [
586
- mongo_path ( 'mongod' ) ,
587
- dir . join ( 'mongod.log' ) . to_s ,
588
- dir . join ( 'mongod.pid' ) . to_s ,
589
- '--dbpath' , dir . to_s ,
590
- '--port' , port . to_s ,
591
- ] + args + server_tls_args + passthrough_args
592
- Helper . spawn_mongo ( *cmd )
593
- record_start_command ( dir , cmd )
589
+ opts = {
590
+ bin_path : mongo_path ( 'mongod' ) ,
591
+ log_path : dir . join ( 'mongod.log' ) . to_s ,
592
+ pid_file_path : dir . join ( 'mongod.pid' ) . to_s ,
593
+ args : [
594
+ '--dbpath' , dir . to_s ,
595
+ '--port' , port . to_s ,
596
+ ] + args + server_tls_args + passthrough_args ,
597
+ }
598
+ Helper . spawn_mongo ( **opts )
599
+ record_start_command ( dir , opts )
594
600
end
595
601
596
602
def spawn_replica_set_node ( dir , port , replica_set_name , args )
597
603
puts ( "Spawn mongod on port #{ port } " )
598
604
FileUtils . mkdir ( dir )
599
- cmd = [
600
- mongo_path ( 'mongod' ) ,
601
- dir . join ( 'mongod.log' ) . to_s ,
602
- dir . join ( 'mongod.pid' ) . to_s ,
603
- '--dbpath' , dir . to_s ,
604
- '--port' , port . to_s ,
605
- '--replSet' , replica_set_name ,
606
- ] + args + server_tls_args + passthrough_args
607
- Helper . spawn_mongo ( *cmd )
608
- record_start_command ( dir , cmd )
609
- end
610
-
611
- def record_start_command ( dir , cmd )
605
+ opts = {
606
+ bin_path : mongo_path ( 'mongod' ) ,
607
+ log_path : dir . join ( 'mongod.log' ) . to_s ,
608
+ pid_file_path : dir . join ( 'mongod.pid' ) . to_s ,
609
+ args : [
610
+ '--dbpath' , dir . to_s ,
611
+ '--port' , port . to_s ,
612
+ '--replSet' , replica_set_name ,
613
+ ] + args + server_tls_args + passthrough_args ,
614
+ }
615
+ Helper . spawn_mongo ( **opts )
616
+ record_start_command ( dir , opts )
617
+ end
618
+
619
+ def record_start_command ( dir , opts )
612
620
dir = dir . to_s
613
621
config [ :settings ] ||= { }
614
622
config [ :settings ] [ dir ] ||= { }
615
- config [ :settings ] [ dir ] [ :start_cmd ] = cmd
623
+ config [ :settings ] [ dir ] [ :start_options ] = opts
616
624
config [ :db_dirs ] << dir unless config [ :db_dirs ] . include? ( dir )
617
625
end
618
626
0 commit comments