Skip to content

Commit

Permalink
Merge pull request #38 from sushmakt/containersscript
Browse files Browse the repository at this point in the history
Added mongodb invocation in container startup script
  • Loading branch information
uttampawar authored Jun 30, 2017
2 parents 146a586 + 3bbd09d commit c100736
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
2 changes: 1 addition & 1 deletion Node-DC-EIS-cluster/config/configuration.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
module.exports = {
'cpu_count' : process.env.CPU_COUNT || 0,
'db_url': process.env.DB_URL || 'mongodb://127.0.0.1:27017/node-els-db',
'app_host' : process.env.SERVER_IP || '127.0.0.1',
'app_host' : process.env.SERVER_IP ,
'app_port' : process.env.SERVER_PORT || 9000,
'app_mode' : 'Cluster',
'count': 10000,
Expand Down
1 change: 1 addition & 0 deletions README-multiple-instance.md
Original file line number Diff line number Diff line change
Expand Up @@ -83,3 +83,4 @@ Auto-login setup between the client and the server
```
bash run_multiple_instance.sh 0
```
- Note that it is preferred to run the mongodb instance on the same host as your node server for a better memory bandwidth utilization
11 changes: 8 additions & 3 deletions container-startup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,15 @@ fi
DB_URL=mongodb://${DB_SERVER_IP}:$DB_PORT/$DB_NAME
echo "$SERVER_PORT:`date +"%T.%3N"`"

if [ CPU_COUNT -eq 0 ]; then
docker run -itd -p $SERVER_PORT:9000 --net node-dc-net -e $DB_URL --name cnodemongo-$SERVER_PORT inode-npm
mkdir ./mongodb$DB_PORT.template
mongod --bind_ip $SERVER_IP --dbpath ./mongodb$DB_PORT.template --port $DB_PORT > /dev/null &

sleep 5

if [ $CPU_COUNT -eq 0 ]; then
docker run -itd -p $SERVER_PORT:9000 --net node-dc-net -e DB_URL=$DB_URL --name cnodemongo-$SERVER_PORT inode-npm
else
docker run -itd -p $SERVER_PORT:9000 --net node-dc-net -e $DB_URL -e CPU_COUNT=$CPU_COUNT --name cnodemongo-$SERVER_PORT inode-npm
docker run -itd -p $SERVER_PORT:9000 --net node-dc-net -e DB_URL=$DB_URL -e CPU_COUNT=$CPU_COUNT --name cnodemongo-$SERVER_PORT inode-npm
fi

while true
Expand Down

0 comments on commit c100736

Please sign in to comment.