Skip to content

Commit

Permalink
pm2: bypass updater when ran with pm2
Browse files Browse the repository at this point in the history
  • Loading branch information
carince committed Oct 12, 2022
1 parent 6bde389 commit 12181a8
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 9 deletions.
15 changes: 9 additions & 6 deletions ecosystem.config.js
@@ -1,8 +1,11 @@
module.exports = {
apps : [{
name : "bloxflip-autocrash",
script : "run start",
max_restarts : 5,
restart_delay : 5000
}]
apps: [{
name: "bloxflip-autocrash",
script: "run start",
max_restarts: 5,
restart_delay: 5000,
env: {
"bypassUpdater": "true"
}
}]
}
4 changes: 1 addition & 3 deletions src/index.ts
Expand Up @@ -11,14 +11,12 @@ import { updater } from "./utils/updater.js";
let page: Page;

(async (): Promise<void> => {
await updater();

Logger.log("STARTUP", "Starting bloxflip-autocrash");
Logger.log("SUPPORT", "Support the developers by giving the repo a star! https://github.com/Norikiru/bloxflip-autocrash");

await sleep(1000);
await updater();

page = await initialize();

Logger.info("BLOXFLIP", "Waiting for network idle...");
Expand Down
5 changes: 5 additions & 0 deletions src/utils/updater.ts
Expand Up @@ -22,6 +22,11 @@ async function updater() {

try {
Logger.log("UPDATER", "Checking for updates...");

if (process.env.bypassUpdater == "true") {
return Logger.info("UPDATER", "Launched with pm2, ignoring updates.")
}

upstreamHash = execSync(`git --git-dir "${gitDir}" rev-parse --short HEAD`).toString().trim();

if (currentHash == upstreamHash) isOutdated = false;
Expand Down

0 comments on commit 12181a8

Please sign in to comment.