Change HTTP server to require a function call to initialize
This commit is contained in:
parent
617c8c4bc5
commit
a82839085f
2
public
2
public
|
@ -1 +1 @@
|
|||
Subproject commit a8a0182686cec166c3042697c639c5ca8b6acf6b
|
||||
Subproject commit 1dc00c7f885ac919a1bda7d4c749d33bd594c42f
|
|
@ -13,14 +13,13 @@
|
|||
// There are a lot of unhinged bs comments in this repo
|
||||
// Pay no attention to the ones that cuss you out
|
||||
|
||||
// If you don't load the server first, bun will literally segfault
|
||||
import "./ws/server";
|
||||
import { loadForcedStartupChannels } from "./channel/forceload";
|
||||
import { Logger } from "./util/Logger";
|
||||
// docker hates this next one
|
||||
import { startReadline } from "./util/readline";
|
||||
import { loadDefaultPermissions } from "./data/permissions";
|
||||
import { loadBehaviors } from "./event/behaviors";
|
||||
import { startHTTPServer } from "./ws/server";
|
||||
|
||||
// wrapper for some reason
|
||||
export function startServer() {
|
||||
|
@ -38,6 +37,8 @@ export function startServer() {
|
|||
// Break the console
|
||||
logger.info("Starting REPL");
|
||||
startReadline();
|
||||
|
||||
startHTTPServer();
|
||||
logger.info("Ready");
|
||||
}
|
||||
|
||||
|
|
|
@ -7,7 +7,7 @@ import { Socket, socketsByUUID } from "./Socket";
|
|||
import env from "../util/env";
|
||||
import { getMOTD } from "../util/motd";
|
||||
import nunjucks from "nunjucks";
|
||||
import type { ServerWebSocket } from "bun";
|
||||
import type { Server, ServerWebSocket } from "bun";
|
||||
import { ConfigManager } from "~/util/config";
|
||||
import { config as usersConfig } from "./usersConfig";
|
||||
|
||||
|
@ -59,7 +59,10 @@ async function getIndex() {
|
|||
|
||||
type ServerWebSocketMPP = ServerWebSocket<{ ip: string; socket: Socket }>;
|
||||
|
||||
export const app = Bun.serve<{ ip: string }>({
|
||||
export let app: Server;
|
||||
|
||||
export function startHTTPServer() {
|
||||
app = Bun.serve<{ ip: string }>({
|
||||
port: env.PORT,
|
||||
hostname: "0.0.0.0",
|
||||
fetch: (req, server) => {
|
||||
|
@ -170,6 +173,7 @@ export const app = Bun.serve<{ ip: string }>({
|
|||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
logger.info("Listening on port", env.PORT);
|
||||
logger.info("Listening on port", env.PORT);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue