Security fixes pass #2
This commit is contained in:
@@ -3,6 +3,10 @@ import path from "path";
|
||||
import type { BunSpawnOptions } from "../../types";
|
||||
import writeErrorFile from "../../functions/write-error-file";
|
||||
|
||||
let retries = 0;
|
||||
let timeout: any;
|
||||
const MAX_RETRIES = 5;
|
||||
|
||||
export default function () {
|
||||
return new Command("start")
|
||||
.description("Start production server")
|
||||
@@ -12,6 +16,13 @@ export default function () {
|
||||
}
|
||||
|
||||
async function start() {
|
||||
clearTimeout(timeout);
|
||||
|
||||
if (retries >= MAX_RETRIES) {
|
||||
console.error(`Production server crashed ${MAX_RETRIES} times. Exiting.`);
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
const dev_spawn_file = path.resolve(__dirname, "prod-spawn.ts");
|
||||
|
||||
const spawn_options: BunSpawnOptions = {
|
||||
@@ -28,6 +39,12 @@ async function start() {
|
||||
|
||||
let dev_process = Bun.spawn(spawn_options);
|
||||
|
||||
retries++;
|
||||
|
||||
timeout = setTimeout(() => {
|
||||
retries = 0;
|
||||
}, 10000);
|
||||
|
||||
const exited = await dev_process.exited;
|
||||
|
||||
if (exited) {
|
||||
|
||||
Reference in New Issue
Block a user