diff --git a/ecosystem.config.js b/ecosystem.config.js index 5dc4852..4b91f1e 100644 --- a/ecosystem.config.js +++ b/ecosystem.config.js @@ -1,23 +1,19 @@ +const { config } = require("dotenv"); + +config = function (branch) { + return { + name: `expressjs-blog${branch}`, + script: "./src/app.js", + instances: 1, // or "max" for cluster mode + exec_mode: "fork", // or "cluster" + 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: [ - { - name: "expressjs-blog", - script: "./src/app.js", - instances: 1, // or "max" for cluster mode - exec_mode: "fork", // or "cluster" - // env: { - // NODE_ENV: "development", - // PORT: 3400, - // }, - // env_production: { - // NODE_ENV: "production", - // PORT: 3000, - // }, - 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", - }, - ], + apps: [config("main"), config("testing")], }; diff --git a/package.json b/package.json index 5f71a31..3dcbf15 100644 --- a/package.json +++ b/package.json @@ -8,8 +8,10 @@ "test": "echo \"Error: no test specified\" && exit 1", "start": "nodemon ./src/app.js --trace-exit", "maildev": "maildev", - "prod": "node_modules/pm2/bin/pm2 start ecosystem.config.js", - "stop": "node_modules/pm2/bin/pm2 delete expressjs-blog" + "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-testing": "node_modules/pm2/bin/pm2 delete expressjs-blog-testing" }, "keywords": [], "author": "", diff --git a/src/routes/analytics.js b/src/routes/analytics.js index 5b5d624..ad7e01f 100644 --- a/src/routes/analytics.js +++ b/src/routes/analytics.js @@ -23,6 +23,6 @@ VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)`, [timestamp, url, referrer, userAgent, viewport, loadTime, event, ip, 1] ); - res.send("Tracked"); - //res.sendStatus(204); + // res.send("Tracked"); + res.sendStatus(204); };