Skip to content

Commit

Permalink
added wait for servers to be up before starting archgraph
Browse files Browse the repository at this point in the history
fixed bug in mongodb connection establishing
  • Loading branch information
silvae86 committed Jun 1, 2020
1 parent 181ac95 commit 8c0ba6c
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
15 changes: 15 additions & 0 deletions conf/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -56,24 +56,39 @@ cd "$ROOT_DIR"

if [[ "$NEO4J_HOST" != "" ]]; then
echo "Neo4j Server Host: $NEO4J_HOST"
else
NEO4J_HOST="127.0.0.1"
fi

if [[ "$NEO4J_PORT" != "" ]]; then
echo "Neo4j Server Port: $NEO4J_PORT"
else
NEO4J_PORT="7687"
fi

if [[ "$MONGODB_HOST" != "" ]]; then
echo "MongoDB Server Host: $MONGODB_HOST"
else
MONGODB_HOST="127.0.0.1"
fi

if [[ "$MONGODB_PORT" != "" ]]; then
echo "MongoDB Server Port: $MONGODB_PORT"
else
MONGODB_PORT="27017"
fi

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

## wait for servers to be active before running the application

./conf/wait-for-it.sh "$MONGODB_HOST:$MONGODB_PORT" --timeout=60 &
./conf/wait-for-it.sh "$NEO4J_HOST:$NEO4J_PORT" --timeout=60

wait

python "$ROOT_DIR/src/Routes/routes.py" &
SERVER_PID=$!
cd "$ROOT_DIR/frontend" || ( echo "folder missing " && exit 1 )
Expand Down
2 changes: 1 addition & 1 deletion src/Routes/mongo.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

client = MongoClient(
host=EnvVarManager.get_from_env_or_return_default("MONGODB_HOST", "localhost"),
port=EnvVarManager.get_from_env_or_return_default("MONGODB_PORT", "27017"),
port=int(EnvVarManager.get_from_env_or_return_default("MONGODB_PORT", "27017")),
)
db = client.mydatabase
date_now = datetime.now().strftime("%Y-%m-%d, %H:%M:%S")
Expand Down

0 comments on commit 8c0ba6c

Please sign in to comment.