From 5b7e418007f38366d353f59013220c0d7e46f84d Mon Sep 17 00:00:00 2001 From: 00Fjongl <65314359+00Fjongl@users.noreply.github.com> Date: Wed, 7 Aug 2024 19:12:21 -0500 Subject: [PATCH] Simplify npm scripts --- package.json | 4 ---- run-command.mjs | 18 ++++++++++-------- 2 files changed, 10 insertions(+), 12 deletions(-) diff --git a/package.json b/package.json index e902cde1..5da019a1 100644 --- a/package.json +++ b/package.json @@ -9,10 +9,6 @@ "restart": "node run-command.mjs stop start", "stop": "node run-command.mjs stop", "test": "npm run proxy-validator", - "pm2-start": "npx pm2 start ecosystem.config.js --env production --watch false", - "pm2-stop": "npx pm2 stop ecosystem.config.js", - "pm2-monit": "npx pm2 monit", - "pm2-nuke": "npx pm2 delete ecosystem.config.js", "manual-start": "node run-command.mjs start", "kill": "node run-command.mjs stop kill", "build": "node run-command.mjs build && cd lib/rammerhead && npm install && npm run build", diff --git a/run-command.mjs b/run-command.mjs index 22aece0d..1f07b67c 100644 --- a/run-command.mjs +++ b/run-command.mjs @@ -28,10 +28,12 @@ for (let i = 2; i < process.argv.length; i++) // config file. case "start": if (config.production) - exec("npm run pm2-start", (error, stdout) => { + exec("npx pm2 start ecosystem.config.js --env production --watch false", + (error, stdout) => { if (error) throw error; console.log(stdout); - }); + } + ); // Handle setup on Windows differently from platforms with POSIX-compliant shells. // This should run the server as a background process. else if (process.platform === "win32") @@ -73,7 +75,7 @@ for (let i = 2; i < process.argv.length; i++) await unlink(shutdown); } if (config.production && !process.argv.slice(i + 1).includes("kill")) - exec("npm run pm2-stop", (error, stdout) => { + exec("npx pm2 stop ecosystem.config.js", (error, stdout) => { if (error) throw error; console.log(stdout); }); @@ -99,13 +101,13 @@ for (let i = 2; i < process.argv.length; i++) break; } -// Kill all node processes and fully reset PM2. To be used for debugging. The -// npm run pm2-nuke is built into the command because, if handled in Node, it -// will not wait for PM2 to actually finish resetting before it closes itself. +// Kill all node processes and fully reset PM2. To be used for debugging. +// Using npx pm2 monit, or npx pm2 list in the terminal will also bring up +// more PM2 debugging tools. case "kill": if (process.platform === "win32") - exec("npm run pm2-nuke ; taskkill /F /IM node*", (error, stdout) => {console.log(stdout)}); - else exec("npm run pm2-nuke ; pkill node", (error, stdout) => {console.log(stdout)}); + exec("( npx pm2 delete ecosystem.config.js ) ; taskkill /F /IM node*", (error, stdout) => {console.log(stdout)}); + else exec("npx pm2 delete ecosystem.config.js; pkill node", (error, stdout) => {console.log(stdout)}); break; // No default case.