From 87531e969c085d08b5e4be4cc99d9df88a895c71 Mon Sep 17 00:00:00 2001 From: MickLesk Date: Sat, 21 Mar 2026 19:17:40 +0100 Subject: [PATCH] fix(anytype-server): wait for MongoDB readiness before rs.initiate() Replace fixed 3-second sleep with a proper readiness loop (up to 60s) that polls MongoDB via ping before attempting replica set initiation. The previous sleep was insufficient on slower systems, causing 'MongoNetworkError: connect ECONNREFUSED 127.0.0.1:27017'. Fixes #13136 --- install/anytype-server-install.sh | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/install/anytype-server-install.sh b/install/anytype-server-install.sh index 9070c2a34..c7d3dd023 100644 --- a/install/anytype-server-install.sh +++ b/install/anytype-server-install.sh @@ -22,7 +22,12 @@ replication: replSetName: "rs0" EOF systemctl restart mongod -sleep 3 +for i in $(seq 1 30); do + if mongosh --quiet --eval "db.adminCommand('ping')" &>/dev/null; then + break + fi + sleep 2 +done $STD mongosh --eval 'rs.initiate({_id: "rs0", members: [{_id: 0, host: "127.0.0.1:27017"}]})' msg_ok "Configured MongoDB Replica Set"