Skip to content

Commit ba4e288

Browse files
authored
Merge pull request #601 from FalkorDB/fix/skip-internal-falkordb-when-external
fix: skip internal FalkorDB when FALKORDB_HOST is external
2 parents 17d1471 + ede7dc4 commit ba4e288

1 file changed

Lines changed: 11 additions & 3 deletions

File tree

start.sh

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,21 @@ set -e
55
FALKORDB_HOST="${FALKORDB_HOST:-localhost}"
66
FALKORDB_PORT="${FALKORDB_PORT:-6379}"
77

8-
# Start FalkorDB Redis server in background
9-
redis-server --loadmodule /var/lib/falkordb/bin/falkordb.so | cat &
8+
# Start FalkorDB Redis server in background only if using a local address (not an external instance)
9+
if [ "${FALKORDB_HOST}" = "localhost" ] || [[ "${FALKORDB_HOST}" =~ ^127\.0\.0\.[0-9]+$ ]]; then
10+
redis-server --loadmodule /var/lib/falkordb/bin/falkordb.so | cat &
11+
fi
1012

1113
# Wait until FalkorDB is ready
12-
echo "Waiting for FalkorDB to start on $FALKORDB_HOST:$FALKORDB_PORT..."
14+
FALKORDB_WAIT_TIMEOUT="${FALKORDB_WAIT_TIMEOUT:-30}"
15+
echo "Waiting for FalkorDB to start on $FALKORDB_HOST:$FALKORDB_PORT (timeout: ${FALKORDB_WAIT_TIMEOUT}s)..."
1316

17+
SECONDS=0
1418
while ! nc -z "$FALKORDB_HOST" "$FALKORDB_PORT"; do
19+
if [ "$SECONDS" -ge "$FALKORDB_WAIT_TIMEOUT" ]; then
20+
echo "ERROR: FalkorDB did not become reachable at $FALKORDB_HOST:$FALKORDB_PORT within ${FALKORDB_WAIT_TIMEOUT}s" >&2
21+
exit 1
22+
fi
1523
sleep 0.5
1624
done
1725

0 commit comments

Comments
 (0)