Skip to content

Commit

Permalink
🐇
Browse files Browse the repository at this point in the history
  • Loading branch information
sharat87 committed Nov 15, 2024
1 parent 2e85d1b commit 86c7684
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 9 deletions.
19 changes: 12 additions & 7 deletions deploy/docker/fs/opt/appsmith/utils/bin/import_db.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,18 @@ async function run(forceOption) {
try {
console.log('stop backend & rts application before import database')
await utils.stop(["backend", "rts"]);
const shellCmdResult = await utils.execCommandReturningOutput([
"mongo",
process.env.APPSMITH_DB_URL,
"--quiet",
"--eval",
"db.getCollectionNames().length",
]);
try {
const shellCmdResult = await utils.execCommandReturningOutput([
"mongo",
process.env.APPSMITH_DB_URL,
"--quiet",
"--eval",
"db.getCollectionNames().length",
]);
} catch (error) {
console.error("Failed to execute mongo command:", error);
throw error;
}
const collectionsLen = parseInt(shellCmdResult.stdout.toString().trimEnd())
if (collectionsLen > 0) {
if (forceOption) {
Expand Down
9 changes: 7 additions & 2 deletions deploy/docker/fs/opt/appsmith/utils/bin/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,13 @@ if (["import-db", "import_db", "im"].includes(command)) {
console.log("Importing database");
// Get Force option flag to run import DB immediately
const forceOption = process.argv[3] === "-f";
import_db.run(forceOption);
console.log("Importing database done");
try {
import_db.run(forceOption);
console.log("Importing database done");
} catch (error) {
console.error("Failed to import database:", error.message);
process.exit(1);
}
return;
}

Expand Down

0 comments on commit 86c7684

Please sign in to comment.