aboutsummaryrefslogtreecommitdiffstats
path: root/gateway/src/index.js
diff options
context:
space:
mode:
authorPinapelz <yukais@pinapelz.com>2026-10-29 19:58:05 -0700
committerPinapelz <yukais@pinapelz.com>2026-10-29 19:58:05 -0700
commit96bfe2e1505b4ae250f2d5201f9541ceb01cec84 (patch)
treeb2164a76dc3aa5b69e160d1135d3385bcbe6108d /gateway/src/index.js
parent150858067059ba615c548f826bb343589993b4bb (diff)
ts web slopify code
Diffstat (limited to 'gateway/src/index.js')
-rw-r--r--gateway/src/index.js39
1 files changed, 39 insertions, 0 deletions
diff --git a/gateway/src/index.js b/gateway/src/index.js
new file mode 100644
index 0000000..28beec5
--- /dev/null
+++ b/gateway/src/index.js
@@ -0,0 +1,39 @@
+import { loadConfig } from "./config.js";
+import { createGatewayServer } from "./server.js";
+import { opusBackendName } from "./opus.js";
+
+const config = loadConfig();
+const log = console;
+
+const { server, shutdown, voiceAvailable } = createGatewayServer(config, log);
+
+server.listen(config.web.port, config.web.host, () => {
+ log.info(`[gateway] listening on http://${config.web.host}:${config.web.port} -> dashboard 127.0.0.1:${config.web.dashboardPort}`);
+ if (voiceAvailable()) {
+ log.info(`[gateway] web voice enabled for ${config.server.host}:${config.server.voicePort} (opus: ${opusBackendName()})`);
+ } else if (!config.server.password) {
+ log.warn("[gateway] web voice disabled: set TS_SERVER_PASSWORD in .env (visitors must know it to join)");
+ } else if (!config.server.host) {
+ log.warn("[gateway] web voice disabled: set TS_HOST");
+ } else {
+ log.warn("[gateway] web voice disabled in config.toml ([voice] enabled = false)");
+ }
+});
+
+server.on("error", (error) => {
+ log.error(`[gateway] ${error.message}`);
+ process.exit(1);
+});
+
+let stopping = false;
+async function stop(signal) {
+ if (stopping) return;
+ stopping = true;
+ log.info(`[gateway] ${signal} received, disconnecting voice sessions`);
+ const force = setTimeout(() => process.exit(0), 3000);
+ force.unref();
+ await shutdown();
+ process.exit(0);
+}
+process.on("SIGINT", () => void stop("SIGINT"));
+process.on("SIGTERM", () => void stop("SIGTERM"));
send patches to the email below
yukais@pinapelz.com
include the subject [PATCH repo_name]
pinapelz.com
homepage