From 86c76844c6d2de12227c94a300e8ce4b46d9b588 Mon Sep 17 00:00:00 2001 From: Shrikant Sharat Kandula Date: Fri, 15 Nov 2024 15:12:01 +0530 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=87?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../fs/opt/appsmith/utils/bin/import_db.js | 19 ++++++++++++------- .../docker/fs/opt/appsmith/utils/bin/index.js | 9 +++++++-- 2 files changed, 19 insertions(+), 9 deletions(-) diff --git a/deploy/docker/fs/opt/appsmith/utils/bin/import_db.js b/deploy/docker/fs/opt/appsmith/utils/bin/import_db.js index ce65c18c533..a23c885f6d6 100644 --- a/deploy/docker/fs/opt/appsmith/utils/bin/import_db.js +++ b/deploy/docker/fs/opt/appsmith/utils/bin/import_db.js @@ -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) { diff --git a/deploy/docker/fs/opt/appsmith/utils/bin/index.js b/deploy/docker/fs/opt/appsmith/utils/bin/index.js index c56b338b61c..a307792d1cd 100755 --- a/deploy/docker/fs/opt/appsmith/utils/bin/index.js +++ b/deploy/docker/fs/opt/appsmith/utils/bin/index.js @@ -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; }