mirror of
https://github.com/QuiteAFancyEmerald/Holy-Unblocker.git
synced 2025-05-12 11:30:01 -04:00
fixed the merge before doom
This commit is contained in:
parent
b39c06d956
commit
40e9cd8d60
1 changed files with 20 additions and 21 deletions
|
@ -56,14 +56,14 @@ commands: for (let i = 2; i < process.argv.length; i++)
|
||||||
// because exiting this program will also terminate backend.js on Windows.
|
// because exiting this program will also terminate backend.js on Windows.
|
||||||
else {
|
else {
|
||||||
const server = fork(
|
const server = fork(
|
||||||
fileURLToPath(new URL("./backend.js", import.meta.url)),
|
fileURLToPath(new URL('./backend.js', import.meta.url)),
|
||||||
{
|
{
|
||||||
cwd: process.cwd(),
|
cwd: process.cwd(),
|
||||||
stdio: ["inherit", "inherit", "pipe", "ipc"],
|
stdio: ['inherit', 'inherit', 'pipe', 'ipc'],
|
||||||
detached: true
|
detached: true,
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
server.stderr.on("data", stderr => {
|
server.stderr.on('data', (stderr) => {
|
||||||
console.error(stderr.toString());
|
console.error(stderr.toString());
|
||||||
process.exitCode = 1;
|
process.exitCode = 1;
|
||||||
});
|
});
|
||||||
|
@ -72,11 +72,12 @@ commands: for (let i = 2; i < process.argv.length; i++)
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
// Stop the server. Make a temporary file that the server will check for if told
|
// Stop the server. Make a temporary file that the server will check for if told
|
||||||
// to shut down. This is done by sending a GET request to the server.
|
// to shut down. This is done by sending a GET request to the server.
|
||||||
case "stop": {
|
case 'stop': {
|
||||||
await writeFile(shutdown, "");
|
await writeFile(shutdown, '');
|
||||||
let timeoutId, hasErrored = false;
|
let timeoutId,
|
||||||
|
hasErrored = false;
|
||||||
try {
|
try {
|
||||||
// Give the server 5 seconds to respond, otherwise cancel this and throw an
|
// Give the server 5 seconds to respond, otherwise cancel this and throw an
|
||||||
// error to the console. The fetch request will also throw an error immediately
|
// error to the console. The fetch request will also throw an error immediately
|
||||||
|
@ -92,29 +93,28 @@ commands: for (let i = 2; i < process.argv.length; i++)
|
||||||
clearTimeout(timeoutId);
|
clearTimeout(timeoutId);
|
||||||
if (response === 'Error') throw new Error('Server is unresponsive.');
|
if (response === 'Error') throw new Error('Server is unresponsive.');
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
// Remove the temporary shutdown file since the server didn't remove it.
|
// Remove the temporary shutdown file since the server didn't remove it.
|
||||||
await unlink(shutdown);
|
await unlink(shutdown);
|
||||||
// Check if this is the error thrown by the fetch request for an unused port.
|
// Check if this is the error thrown by the fetch request for an unused port.
|
||||||
// Don't print the unused port error, since nothing has actually broken.
|
// Don't print the unused port error, since nothing has actually broken.
|
||||||
if (e instanceof TypeError) clearTimeout(timeoutId);
|
if (e instanceof TypeError) clearTimeout(timeoutId);
|
||||||
else {
|
else {
|
||||||
console.error(e);
|
console.error(e);
|
||||||
// Stop here unless Node will be killed later.
|
// Stop here unless Node will be killed later.
|
||||||
if (!process.argv.slice(i + 1).includes("kill"))
|
if (!process.argv.slice(i + 1).includes('kill')) hasErrored = true;
|
||||||
hasErrored = true;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Do not run this if Node will be killed later in this script. It will fail.
|
// Do not run this if Node will be killed later in this script. It will fail.
|
||||||
if (config.production && !process.argv.slice(i + 1).includes("kill"))
|
if (config.production && !process.argv.slice(i + 1).includes('kill'))
|
||||||
exec("npx pm2 stop ecosystem.config.js", (error, stdout) => {
|
exec('npx pm2 stop ecosystem.config.js', (error, stdout) => {
|
||||||
if (error) {
|
if (error) {
|
||||||
console.error(error);
|
console.error(error);
|
||||||
hasErrored = true;
|
hasErrored = true;
|
||||||
}
|
}
|
||||||
console.log(stdout);
|
console.log(stdout);
|
||||||
});
|
});
|
||||||
// Do not continue executing commands since the server was unable to be stopped.
|
// Do not continue executing commands since the server was unable to be stopped.
|
||||||
// Mostly implemented to prevent duplicating Node instances with npm restart.
|
// Mostly implemented to prevent duplicating Node instances with npm restart.
|
||||||
if (hasErrored) {
|
if (hasErrored) {
|
||||||
process.exitCode = 1;
|
process.exitCode = 1;
|
||||||
break commands;
|
break commands;
|
||||||
|
@ -165,5 +165,4 @@ commands: for (let i = 2; i < process.argv.length; i++)
|
||||||
// No default case.
|
// No default case.
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
process.exitCode = process.exitCode || 0;
|
process.exitCode = process.exitCode || 0;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue