17 lines
307 B
JavaScript
17 lines
307 B
JavaScript
function waitForPrimary() {
|
|
while (true) {
|
|
try {
|
|
rs.initiate({
|
|
_id: "rs0",
|
|
members: [{ _id: 0, host: "localhost:27017" }],
|
|
});
|
|
break;
|
|
} catch (e) {
|
|
print("Replica set initiation failed, retrying in 2s...");
|
|
sleep(2000);
|
|
}
|
|
}
|
|
}
|
|
|
|
waitForPrimary();
|