wip fix
This commit is contained in:
@@ -190,6 +190,7 @@ export const downloadFile = async (
|
||||
if (_url.hostname === "localhost") {
|
||||
_url.hostname = "127.0.0.1";
|
||||
}
|
||||
g.log.info(`Downloading ${url} to ${filePath}`);
|
||||
const res = await fetch(_url);
|
||||
if (res.body) {
|
||||
const file = Bun.file(filePath);
|
||||
|
||||
+8
-1
@@ -5,13 +5,20 @@ import { config } from "./utils/config";
|
||||
import { g } from "./utils/global";
|
||||
import { createLogger } from "./utils/logger";
|
||||
import { loadWeb } from "./server/load-web";
|
||||
import { ensureNotRunning } from "utils/ensure";
|
||||
import { ensureNotRunning, randomBetween } from "utils/ensure";
|
||||
import { preparePrisma } from "utils/prisma";
|
||||
import { startDevWatcher } from "utils/dev-watcher";
|
||||
|
||||
g.mode = process.argv.includes("dev") ? "dev" : "prod";
|
||||
g.datadir = g.mode === "prod" ? "../data" : ".data";
|
||||
|
||||
if (!process.env.PORT) {
|
||||
g.port = randomBetween(5000, 15000);
|
||||
await Bun.write(".env", `PORT=${g.port}`);
|
||||
} else {
|
||||
g.port = parseInt(process.env.PORT);
|
||||
}
|
||||
|
||||
await preparePrisma();
|
||||
await createLogger();
|
||||
await ensureNotRunning();
|
||||
|
||||
@@ -26,7 +26,7 @@ export const ensureNotRunning = async () => {
|
||||
};
|
||||
|
||||
if (!(await checkPort())) {
|
||||
g.log.warn(`Port ${process.env.PORT} is used, waiting...`);
|
||||
g.log.warn(`Port ${g.port} is used, waiting...`);
|
||||
setInterval(async () => {
|
||||
if (await checkPort()) resolve();
|
||||
}, 500);
|
||||
@@ -35,3 +35,7 @@ export const ensureNotRunning = async () => {
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
export function randomBetween(min: number, max: number) {
|
||||
return Math.floor(Math.random() * (max - min + 1) + min);
|
||||
}
|
||||
|
||||
@@ -11,7 +11,6 @@ export const preparePrisma = async () => {
|
||||
const { PrismaClient } = await import("../../app/db/db");
|
||||
g.db = new PrismaClient();
|
||||
}
|
||||
|
||||
|
||||
g.dburl = process.env.DATABASE_URL || "";
|
||||
g.port = parseInt(process.env.PORT || "3000");
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user