Skip to content

Commit b1791da

Browse files
committed
chore: better logging
1 parent 1d78eae commit b1791da

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

start-mongodb.sh

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -103,23 +103,24 @@ if [ -z "$MONGODB_REPLICA_SET" ]; then
103103
exit 0
104104
fi
105105

106-
# For replica set mode:
107-
# If auth (username/password) is requested, ensure mongodb-key is provided, otherwise generate random
108-
if { [ -n "$MONGODB_USERNAME" ] || [ -n "$MONGODB_PASSWORD" ]; } && [ -z "$MONGODB_KEY" ]; then
109-
MONGODB_KEY=$(dd if=/dev/urandom bs=256 count=1 2>/dev/null | base64 | tr -d '\n')
110-
fi
111-
112106
echo "::group::Starting MongoDB as single-node replica set"
113107
echo " - port [$MONGODB_PORT]"
114108
echo " - version [$MONGODB_VERSION]"
115109
echo " - replica set [$MONGODB_REPLICA_SET]"
116110
if [ -n "$MONGODB_KEY" ]; then
117111
echo " - keyFile provided: yes"
118112
else
119-
echo " - keyFile provided: no"
113+
echo " - keyFile provided: no (random)"
120114
fi
121115
echo ""
122116

117+
# For replica set mode:
118+
# If auth (username/password) is requested, ensure mongodb-key is provided, otherwise generate random
119+
if { [ -n "$MONGODB_USERNAME" ] || [ -n "$MONGODB_PASSWORD" ]; } && [ -z "$MONGODB_KEY" ]; then
120+
MONGODB_KEY=$(dd if=/dev/urandom bs=256 count=1 2>/dev/null | base64 | tr -d '\n')
121+
fi
122+
123+
123124
# Start mongod in replica set mode, with optional auth and keyFile
124125
# MONGO_INITDB_* envs will create the root user on first startup
125126

0 commit comments

Comments
 (0)