File tree 1 file changed +11
-13
lines changed
1 file changed +11
-13
lines changed Original file line number Diff line number Diff line change @@ -616,7 +616,7 @@ function setUpMongoDB() {
616
616
617
617
console . log ( "Looking for a MongoDB Cluster..." ) ;
618
618
619
- if ( ( ! global . config && ! process . env [ "MONGO_1_PORT_27017_TCP_ADDR" ] && ! process . env [ "MONGO_SERVICE_HOST" ] ) || ( ! global . config && ! process . env [ "MONGO_PORT_27017_TCP_ADDR" ] && ! process . env [ "MONGO_SERVICE_HOST "] ) ) {
619
+ if ( ( ! global . config && ! process . env [ "MONGO_1_PORT_27017_TCP_ADDR" ] && ! process . env [ "KUBERNETES_STATEFUL_MONGO_URL " ] ) ) {
620
620
console . error ( "INFO : Not running on Docker. Use docker-compose (recommended) from https://github.com/cloudboost/docker" ) ;
621
621
}
622
622
@@ -652,19 +652,17 @@ function setUpMongoDB() {
652
652
}
653
653
global . config . mongo = [ ] ;
654
654
655
- if ( process . env [ "MONGO1_SERVICE_HOST " ] ) {
655
+ if ( process . env [ "KUBERNETES_STATEFUL_MONGO_URL " ] ) {
656
656
console . log ( "MongoDB is running on Kubernetes" ) ;
657
- var i = 1 ;
658
- while ( process . env [ "MONGO" + i + "_SERVICE_HOST" ] ) {
659
- global . config . mongo . push ( {
660
- host : process . env [ "MONGO" + i + "_SERVICE_HOST" ] ,
661
- port : process . env [ "MONGO" + i + "_SERVICE_PORT" ]
662
- } ) ;
663
- mongoConnectionString += process . env [ "MONGO" + i + "_SERVICE_HOST" ] + ":" + process . env [ "MONGO" + i + "_SERVICE_PORT" ] ;
664
- mongoConnectionString += "," ;
665
- ++ i ;
666
- }
667
-
657
+
658
+ global . config . mongo = process . env [ "KUBERNETES_STATEFUL_MONGO_URL" ] . split ( ',' ) . map ( function ( x , i ) {
659
+ return {
660
+ host :x . split ( ':' ) [ 0 ] ,
661
+ port :x . split ( ':' ) [ 1 ]
662
+ }
663
+ } )
664
+
665
+ mongoConnectionString += process . env [ "KUBERNETES_STATEFUL_MONGO_URL" ]
668
666
isReplicaSet = true ;
669
667
670
668
} else {
You can’t perform that action at this time.
0 commit comments