Spaces:
Runtime error
Runtime error
update data dir
Browse files
start.sh
CHANGED
@@ -1,6 +1,9 @@
|
|
1 |
#!/bin/bash
|
2 |
set -x -e
|
3 |
|
|
|
|
|
|
|
4 |
echo "Starting MongoDB..."
|
5 |
mongod --config /etc/mongod.conf &
|
6 |
|
@@ -15,7 +18,7 @@ while ! mongosh --quiet --eval "db.version()" > /dev/null 2>&1; do
|
|
15 |
if [ $attempt -gt $max_attempts ]; then
|
16 |
echo "MongoDB failed to start. Showing logs:"
|
17 |
cat /var/log/mongodb.log
|
18 |
-
exit
|
19 |
fi
|
20 |
echo "Attempt $attempt of $max_attempts: MongoDB not ready yet..."
|
21 |
sleep 2
|
@@ -28,7 +31,7 @@ echo "MongoDB started successfully"
|
|
28 |
echo "Initializing replica set..."
|
29 |
mongosh --eval 'rs.initiate({_id: "rs01", members: [{_id: 0, host: "localhost:27017"}]})' || {
|
30 |
echo "Failed to initialize replica set"
|
31 |
-
exit
|
32 |
}
|
33 |
|
34 |
echo "Waiting for replica set to initialize..."
|
|
|
1 |
#!/bin/bash
|
2 |
set -x -e
|
3 |
|
4 |
+
echo "Creating data directory..."
|
5 |
+
mkdir -p /data/db
|
6 |
+
|
7 |
echo "Starting MongoDB..."
|
8 |
mongod --config /etc/mongod.conf &
|
9 |
|
|
|
18 |
if [ $attempt -gt $max_attempts ]; then
|
19 |
echo "MongoDB failed to start. Showing logs:"
|
20 |
cat /var/log/mongodb.log
|
21 |
+
exit 1
|
22 |
fi
|
23 |
echo "Attempt $attempt of $max_attempts: MongoDB not ready yet..."
|
24 |
sleep 2
|
|
|
31 |
echo "Initializing replica set..."
|
32 |
mongosh --eval 'rs.initiate({_id: "rs01", members: [{_id: 0, host: "localhost:27017"}]})' || {
|
33 |
echo "Failed to initialize replica set"
|
34 |
+
exit 1
|
35 |
}
|
36 |
|
37 |
echo "Waiting for replica set to initialize..."
|