Skip to content

Commit

Permalink
update pm2 checking
Browse files Browse the repository at this point in the history
  • Loading branch information
bugsounet committed Nov 9, 2024
1 parent 50127a1 commit cfd393c
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions components/controler.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,22 +17,29 @@ class Controler {
resolve(false);
return;
}

if (process.env.unique_id === undefined) {
console.log("[GA] You don't use PM2");
resolve(false);
return;
}

pm2.list((err, list) => {
if (err) {
console.error("GA] Can't get pm2 process List!", err);
resolve(false);
return;
}
list.forEach((pm) => {
if (pm.pm2_env.status === "online" && process.env.name === pm.name && +process.env.pm_id === +pm.pm_id) {
if (pm.pm2_env.status === "online" && process.env.name === pm.name && +process.env.pm_id === +pm.pm_id && process.env.unique_id === pm.pm2_env.unique_id) {
this.usePM2 = true;
this.PM2Process = pm.name;
console.log("[GA] You are using PM2 with", this.PM2Process);
this.PM2Process = pm.pm_id;
console.log(`[GA] You are using pm2 with id: ${this.PM2Process} (${pm.name})`);
resolve(true);
}
});
pm2.disconnect();
if (!this.PM2Process) {
if (!this.usePM2) {
console.log("[GA] You don't use PM2");
resolve(false);
}
Expand Down

0 comments on commit cfd393c

Please sign in to comment.