Skip to content

Commit

Permalink
Fix mongodb connection string
Browse files Browse the repository at this point in the history
  • Loading branch information
silvae86 committed May 26, 2020
1 parent db36ba9 commit a125722
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 4 deletions.
12 changes: 12 additions & 0 deletions conf/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,18 @@ nvm use v10
echo "Starting archgraph server at $ROOT_DIR"
cd "$ROOT_DIR"

if [[ "$NEO4J_CONNECTION_STRING" != "" ]]; then
echo "Neo4j Server at $NEO4J_CONNECTION_STRING";
fi

if [[ "$MONGODB_CONNECTION_STRING" != "" ]]; then
echo "MongoDB Server at $MONGODB_CONNECTION_STRING";
fi

if [[ "$CUSTOM_HOST_FOR_SERVER_BIND" != "" ]]; then
echo "Flask Server binding to host with address $CUSTOM_HOST_FOR_SERVER_BIND";
fi

python "$ROOT_DIR/src/Routes/routes.py" --neo4j="$NEO4J_CONNECTION_STRING" --mongodb="$MONGODB_CONNECTION_STRING" --host="$CUSTOM_HOST_FOR_SERVER_BIND" &
SERVER_PID=$!
cd "$ROOT_DIR/frontend" || ( echo "folder missing " && exit 1 )
Expand Down
4 changes: 2 additions & 2 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ services:
PRELOAD_GRAPH: "true"
context: .
environment:
- "NEO4J_CONNECTION_STRING=bolt://neo4j:password@neo4j:7687"
- "MONGODB_CONNECTION_STRING=mongodb://root:rootpassword@mongodb:27017"
- "NEO4J_CONNECTION_STRING=bolt://neo4j:password@archgraph-neo4j:7687"
- "MONGODB_CONNECTION_STRING=mongodb://root:rootpassword@archgraph-mongodb:27017"
- "CUSTOM_HOST_FOR_SERVER_BIND=0.0.0.0"
- "RUN_IN_PRODUCTION=1"
ports:
Expand Down
12 changes: 10 additions & 2 deletions src/Routes/mongo.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,24 @@
import json
from datetime import datetime
from pymongo import MongoClient
from pymongo import MongoClient, uri_parser


import src.Utils.ArgParser as ArgParser
args = ArgParser.parse()

MONGODB_URL = "mongodb://root:rootpassword@localhost:27017"

if args.mongodb is not None and args.mongodb != "":
# mongodb_arguments = uri_parser.parse_uri(args.mongodb)
# client = MongoClient(host=mongodb_arguments.nodelist.first(),
# port= mongodb_arguments.port,
# username=mongodb_arguments.username,
# password=mongodb_arguments.password,
# server_selection_timeout=1
# )
MONGODB_URL = args.mongodb

client = MongoClient(host=MONGODB_URL)
client = MongoClient(MONGODB_URL)
db = client.mydatabase
date_now = datetime.now().strftime("%Y-%m-%d, %H:%M:%S")

Expand Down

0 comments on commit a125722

Please sign in to comment.