forked from jmug/stoatchat
feat: initiate mongo replset by default
Signed-off-by: Zomatree <me@zomatree.live>
This commit is contained in:
@@ -4,7 +4,7 @@
|
|||||||
[database]
|
[database]
|
||||||
# MongoDB connection URL
|
# MongoDB connection URL
|
||||||
# Defaults to the container name specified in self-hosted
|
# Defaults to the container name specified in self-hosted
|
||||||
mongodb = "mongodb://127.0.0.1:27017"
|
mongodb = "mongodb://127.0.0.1:27017?directConnection=true&replicaSet=rs0"
|
||||||
# Redis connection URL
|
# Redis connection URL
|
||||||
# Defaults to the container name specified in self-hosted
|
# Defaults to the container name specified in self-hosted
|
||||||
redis = "redis://127.0.0.1:6379/"
|
redis = "redis://127.0.0.1:6379/"
|
||||||
|
|||||||
19
compose.yml
19
compose.yml
@@ -8,10 +8,29 @@ services:
|
|||||||
# MongoDB
|
# MongoDB
|
||||||
database:
|
database:
|
||||||
image: mongo
|
image: mongo
|
||||||
|
command: ["--replSet", "rs0", "--bind_ip_all"]
|
||||||
ports:
|
ports:
|
||||||
- "27017:27017"
|
- "27017:27017"
|
||||||
volumes:
|
volumes:
|
||||||
- ./.data/db:/data/db
|
- ./.data/db:/data/db
|
||||||
|
- ./scripts/mongo-init.js:/docker-entrypoint-initdb.d/mongo-init.js:ro
|
||||||
|
healthcheck:
|
||||||
|
test: >
|
||||||
|
mongosh --quiet --eval "
|
||||||
|
try {
|
||||||
|
const status = rs.status();
|
||||||
|
if (status.ok === 1 && status.members[0].stateStr === 'PRIMARY') {
|
||||||
|
quit(0);
|
||||||
|
} else {
|
||||||
|
quit(1);
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
quit(1);
|
||||||
|
}"
|
||||||
|
interval: 5s
|
||||||
|
timeout: 5s
|
||||||
|
retries: 10
|
||||||
|
start_period: 10s
|
||||||
ulimits:
|
ulimits:
|
||||||
nofile:
|
nofile:
|
||||||
soft: 65536
|
soft: 65536
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
[database]
|
[database]
|
||||||
mongodb = "mongodb://localhost"
|
mongodb = "mongodb://localhost?directConnection=true&replicaSet=rs0"
|
||||||
redis = "redis://localhost/"
|
redis = "redis://localhost/"
|
||||||
|
|
||||||
[rabbit]
|
[rabbit]
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ disable_events_dont_use = false
|
|||||||
[database]
|
[database]
|
||||||
# MongoDB connection URL
|
# MongoDB connection URL
|
||||||
# Defaults to the container name specified in self-hosted
|
# Defaults to the container name specified in self-hosted
|
||||||
mongodb = "mongodb://database"
|
mongodb = "mongodb://database?directConnection=true&replicaSet=rs0"
|
||||||
# Redis connection URL
|
# Redis connection URL
|
||||||
# Defaults to the container name specified in self-hosted
|
# Defaults to the container name specified in self-hosted
|
||||||
redis = "redis://redis/"
|
redis = "redis://redis/"
|
||||||
|
|||||||
5
scripts/mongo-init.js
Normal file
5
scripts/mongo-init.js
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
try {
|
||||||
|
rs.status();
|
||||||
|
} catch (e) {
|
||||||
|
rs.initiate({ _id: "rs0", members: [{ _id: 0, host: "localhost:27017" }] });
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user