Add logs for server start
This commit is contained in:
@@ -1,8 +1,11 @@
|
||||
console.log("Imports loading...");
|
||||
import { parseMagnetURI, BencodeDecoder, BencodeEncoder, MetadataReassembler } from "@torrent-client/shared";
|
||||
console.log("Shared loaded");
|
||||
import dgram from "node:dgram";
|
||||
import crypto from "node:crypto";
|
||||
import { join } from "node:path";
|
||||
import { TorrentManager } from "./engine";
|
||||
console.log("Engine loaded");
|
||||
|
||||
const port = process.env.PORT || 3001;
|
||||
const getCONFIG = () => ({
|
||||
@@ -309,9 +312,18 @@ export async function handleRequest(req: Request): Promise<Response> {
|
||||
return new Response(Bun.file(join(distPath, "index.html")));
|
||||
}
|
||||
|
||||
if (process.env.NODE_ENV !== "test") {
|
||||
Bun.serve({
|
||||
port: port,
|
||||
fetch: handleRequest
|
||||
});
|
||||
console.log("Server process starting...");
|
||||
|
||||
try {
|
||||
if (process.env.NODE_ENV !== "test") {
|
||||
console.log(`Attempting to bind parameters: PORT=${port}`);
|
||||
const server = Bun.serve({
|
||||
port: port,
|
||||
fetch: handleRequest
|
||||
});
|
||||
console.log(`Server successfully listening on port ${server.port}`);
|
||||
}
|
||||
} catch (e) {
|
||||
console.error("CRITICAL SERVER STARTUP ERROR:", e);
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user