@@ -54,33 +54,50 @@ def write_reg(self, cid):
5454 config = {'cid' : cid ,
5555 'ip' : self .registry_ip ,
5656 'host_ip' : self .host_ip ,
57- 'host_port' : self .registry_port ,
58- 'type' : 'registry' }
57+ 'host_port' : self .registry_port , 'type' : 'registry' }
5958 wrjs (config_path , config )
6059
6160 print 'Started registry "localhost:%s"' % self .registry_port
6261
63- def start_olreg (self ):
62+ def start_olreg (self , num ):
63+ nodes = []
6464 c = 'docker run -d -p 28015:28015 -p 29015:29015 rethinkdb rethinkdb --bind all'
65-
66- # for subsequent hosts in cluster:
67- #c = 'docker run -d -p 28015:28015 -p 29015:29015 dockerfile/rethinkdb rethinkdb --bind all -j <first-host-ip>:29015'
6865 cid = run (c ).strip ()
69-
70- self .rethinkdb_ip = container_ip (cid )
71- self .rethinkdb_port = lookup_host_port (cid , 28015 )
72-
73- print 'Started rethinkdb container "%s:%s"' % (self .rethinkdb_ip , "28015" )
74-
75- config_path = os .path .join (self .cluster_dir , 'registry.json' )
76- config = {'cid' : cid ,
77- 'ip' : self .rethinkdb_ip ,
78- 'host_ip' : self .host_ip ,
79- 'host_port' : self .rethinkdb_port ,
80- 'type' : 'rethinkdb' }
66+ cluster_ip = container_ip (cid )
67+ cluster_port = lookup_host_port (cid , 28015 )
68+ nodes .append ({'cid' : cid ,
69+ 'ip' : cluster_ip ,
70+ 'host_ip' : self .host_ip ,
71+ 'host_port' : cluster_port })
72+
73+ print 'Started rethinkdb instance "localhost:28015"'
74+ print 40 * '='
75+
76+ for k in range (1 , num ):
77+ client_port = 28015 + k
78+ comm_port = 29015 + k
79+ c = 'docker run -d -p %s:%s -p %s:%s rethinkdb rethinkdb --port-offset %s --bind all -j %s:29015' % (client_port , client_port , comm_port , comm_port , k , cluster_ip )
80+ cid = run (c ).strip ()
81+ host_port = lookup_host_port (cid , 28015 + k )
82+ nodes .append ({'cid' : cid ,
83+ 'ip' : container_ip (cid ),
84+ 'host_ip' : self .host_ip ,
85+ 'host_port' : host_port })
86+
87+ print 'Started rethinkdb container "localhost:%s"' % host_port
88+ print 40 * '='
89+
90+ config_path = os .path .join (self .cluster_dir , 'rethinkdb.json' )
91+ config = {
92+ 'cluster' : nodes ,
93+ 'ip' : nodes [0 ]['ip' ],
94+ 'host_ip' : self .host_ip ,
95+ 'host_port' : nodes [0 ]['host_port' ],
96+ 'type' : 'rethinkdb'
97+ }
8198 wrjs (config_path , config )
8299
83- c = 'docker run -d -p 0:%s olregistry /open-lambda/registry %s:%s' % (self .internal_reg_port , self . rethinkdb_ip , "28015" )
100+ c = 'docker run -d -p 0:%s olregistry /open-lambda/registry %s:%s' % (self .internal_reg_port , cluster_ip , cluster_port )
84101 cid = run (c ).strip ()
85102
86103 self .write_reg (cid )
@@ -115,7 +132,7 @@ def start_workers(self):
115132 config ['host_port' ] = lookup_host_port (cid , self .internal_worker_port )
116133 wrjs (config_path , config , atomic = True )
117134
118- print 'Started worker "localhost:%s"' % config ['host_port' ]
135+ print 'Started worker container "localhost:%s"' % config ['host_port' ]
119136 self .workers .append (config )
120137
121138 def start_lb (self ):
@@ -137,7 +154,7 @@ def start_lb(self):
137154 config_path = os .path .join (self .cluster_dir , 'loadbalancer-%d.json' % 1 )
138155 wrjs (config_path , config , atomic = True )
139156
140- print 'Started loadbalancer "localhost:%s"' % self .balancer_port
157+ print 'Started loadbalancer container "localhost:%s"' % self .balancer_port
141158
142159 def write_nginx_config (self , path ):
143160 config = 'http {\n \t upstream handlers {\n '
@@ -158,7 +175,7 @@ def rethinkdb_wait(self):
158175 if up < len (self .workers ):
159176 print '%d of %d rethinkdb instances are ready' % (up , len (self .workers ))
160177 except :
161- print 'waiting for first rethinkdb instance to come up'
178+ print 'Waiting for first rethinkdb instance to come up'
162179
163180 time .sleep (1 )
164181
0 commit comments