add mongo config
This commit is contained in:
1 parent
6f4ca57fa8
commit
68cac694ed
2 files changed
+31
No files matched your search
+16
@@ -0,0 +1,16 @@
|
|||||||
|
var username = process.env.USERNAME_ENV_VAR;
|
||||||
|
var password = process.env.PASSWORD_ENV_VAR;
|
||||||
|
|
||||||
|
db = db.getSiblingDB("uptime_db");
|
||||||
|
|
||||||
|
db.createUser({
|
||||||
|
user: username,
|
||||||
|
pwd: password,
|
||||||
|
roles: [
|
||||||
|
{
|
||||||
|
role: "readWrite",
|
||||||
|
db: "uptime_db",
|
||||||
|
},
|
||||||
|
],
|
||||||
|
});
|
||||||
|
print("User uptime_user created successfully");
|
||||||
+15
@@ -0,0 +1,15 @@
|
|||||||
|
try {
|
||||||
|
const status = rs.status();
|
||||||
|
printjson(status);
|
||||||
|
} catch (e) {
|
||||||
|
if (e.codeName === "NotYetInitialized") {
|
||||||
|
print("Replica set not initialized. Initiating...");
|
||||||
|
rs.initiate({
|
||||||
|
_id: "rs0",
|
||||||
|
members: [{ _id: 0, host: "mongodb:27017" }],
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
print("Unexpected error during rs.status():");
|
||||||
|
printjson(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in new issue
Block a user