From 0688bf34d4468d5fda6a5859b79c8af3d0fd6e9e Mon Sep 17 00:00:00 2001 From: adriano Date: Mon, 10 Apr 2023 11:29:16 -0300 Subject: [PATCH] =?UTF-8?q?Altera=C3=A7=C3=A3o=20para=20salvar=20a=20lista?= =?UTF-8?q?=20do=20pm2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- TEST_SERVER1/api/helpers/startPm2Process.js | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/TEST_SERVER1/api/helpers/startPm2Process.js b/TEST_SERVER1/api/helpers/startPm2Process.js index f9ca073..13bd3d6 100644 --- a/TEST_SERVER1/api/helpers/startPm2Process.js +++ b/TEST_SERVER1/api/helpers/startPm2Process.js @@ -1,4 +1,5 @@ const pm2 = require('pm2'); +const { execSync } = require("child_process"); function startPm2Process(process_name, file, path, port) { @@ -14,13 +15,26 @@ function startPm2Process(process_name, file, path, port) { cwd: path, env: { PORT: port - } + } // additional options here if needed }, function (err, apps) { if (err) { console.error(err); // process.exit(2); } + else { + execSync(`pm2 save --force`, { cwd: path }, (error, stdout, stderr) => { + if (error) { + console.log(`error: ${error.message}`); + return; + } + if (stderr) { + console.log(`stderr: ${stderr}`); + return; + } + console.log(`stdout: ${stdout}`); + }); + } pm2.disconnect(); });