fix duplicate bottos
This commit is contained in:
parent
9894f25f8f
commit
13eb492cab
1 changed files with 19 additions and 3 deletions
20
build.mjs
20
build.mjs
|
@ -1,5 +1,6 @@
|
|||
import { build } from "esbuild";
|
||||
import { spawn } from "child_process";
|
||||
import { execSync } from "child_process";
|
||||
|
||||
/**
|
||||
* @type {esbuild.Plugin}
|
||||
|
@ -34,8 +35,23 @@ await build({
|
|||
setInterval(() => {}, 100);
|
||||
|
||||
if (process.argv.includes("start")) {
|
||||
const proc = spawn("node", ["--env-file=.env", "dist/index.js"], {
|
||||
try {
|
||||
execSync(
|
||||
`ps aux | grep '[n]ode.*dist/index.js --i-am-apprev' | awk '{print $2}' | xargs -r kill -9`,
|
||||
{ stdio: "ignore" }
|
||||
);
|
||||
} catch {
|
||||
console.error(
|
||||
"Failed to kill old bot. Duplicate instances may run.\nIf you are on Windows use WSL/Linux"
|
||||
);
|
||||
}
|
||||
const proc = spawn(
|
||||
"node",
|
||||
["--env-file=.env", "dist/index.js", "--i-am-apprev"],
|
||||
{
|
||||
stdio: "inherit"
|
||||
});
|
||||
}
|
||||
);
|
||||
proc.on("exit", (code) => process.exit(code));
|
||||
proc.on("close", (code) => process.exit(code));
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue