diff --git a/ecosystem.config.js b/ecosystem.config.js index 4b91f1e..0746851 100644 --- a/ecosystem.config.js +++ b/ecosystem.config.js @@ -1,19 +1,20 @@ -const { config } = require("dotenv"); +const dotenv = require("dotenv"); +dotenv.config(); // optional, if loading .env -config = function (branch) { +function createAppConfig(branch) { return { - name: `expressjs-blog${branch}`, + name: `expressjs-blog-${branch}`, script: "./src/app.js", - instances: 1, // or "max" for cluster mode - exec_mode: "fork", // or "cluster" + instances: 1, + exec_mode: "fork", ignore_watch: ["pids", "data", "node_modules", "logs"], log_date_format: "YYYY-MM-DD HH:mm Z", error_file: "./logs/err.log", out_file: "./logs/out.log", pid_file: "./pids/pm2.pid", }; -}; +} module.exports = { - apps: [config("main"), config("testing")], + apps: [createAppConfig("main"), createAppConfig("testing")], }; diff --git a/package.json b/package.json index 3dcbf15..9ece88e 100644 --- a/package.json +++ b/package.json @@ -10,7 +10,7 @@ "maildev": "maildev", "main": "pm2 start ecosystem.config.js --only expressjs-blog-main", "testing": "pm2 start ecosystem.config.js --only expressjs-blog-testing", - "stop": "node_modules/pm2/bin/pm2 delete expressjs-blog-main", + "stop-main": "node_modules/pm2/bin/pm2 delete expressjs-blog-main", "stop-testing": "node_modules/pm2/bin/pm2 delete expressjs-blog-testing" }, "keywords": [],