This commit is contained in:
Rizky 2024-07-29 18:45:11 +07:00
parent 6df0d20576
commit 5f97ccb5c4
3 changed files with 27 additions and 9 deletions

View File

@ -163,6 +163,14 @@ export const _ = {
await deploy.init();
const deploys = fs.readdirSync(dir(`/app/web/deploy`));
if (g.main.process) {
setTimeout(() => {
if (g.main.process) {
g.main.process.kill();
}
}, 500);
}
return {
now: Date.now(),
current: parseInt(deploy.config.deploy.ts),

View File

@ -4,7 +4,15 @@ import exitHook from "exit-hook";
import { existsAsync } from "fs-jetpack";
import { dir } from "utils/dir";
import { checkPort, randomBetween } from "utils/ensure";
import { g } from "utils/global";
g.main = {
process: null as null | Subprocess,
restart: {
timeout: null as any,
},
};
const main = g.main;
let port = 0;
try {
@ -26,17 +34,13 @@ exitHook((signal) => {
console.log(`Exiting with signal: ${signal}`);
});
const main = {
process: null as null | Subprocess,
restart: {
timeout: null as any,
},
};
console.log("Process Manager running at port:", port);
if (process.env.DATABASE_URL) {
if (!(await existsAsync(dir("node_modules/.prisma"))) && process.env.DATABASE_URL) {
if (
!(await existsAsync(dir("node_modules/.prisma"))) &&
process.env.DATABASE_URL
) {
try {
await Bun.write(
dir("app/db/.env"),

View File

@ -1,4 +1,4 @@
import { Server, WebSocketHandler } from "bun";
import { Server, Subprocess, WebSocketHandler } from "bun";
import { Logger } from "pino";
import { RadixRouter } from "radix3";
import { PrismaClient } from "../../app/db/db";
@ -47,6 +47,12 @@ export const g = global as unknown as {
log: Logger;
firebaseInit: boolean;
firebase: admin.app.App;
main: {
process: null | Subprocess;
restart: {
timeout: any;
};
};
notif: {
db: Database;
};