Replace polling with websocket live sync

This commit is contained in:
2026-04-02 02:31:59 +03:00
parent 9a3785deb9
commit c04847b21c
15 changed files with 596 additions and 28 deletions

View File

@@ -1,8 +1,10 @@
import { createServer } from 'node:http';
import path from 'node:path';
import fs from 'node:fs/promises';
import { createApp } from './app';
import { AuthService } from './lib/auth';
import { buildRuntimePaths, render3proxyConfig } from './lib/config';
import { LiveSyncServer } from './lib/liveSync';
import { ThreeProxyManager } from './lib/runtime';
import { StateStore } from './lib/store';
@@ -34,8 +36,13 @@ async function main() {
await fs.mkdir(path.dirname(runtimePaths.configPath), { recursive: true });
await fs.writeFile(runtimePaths.configPath, render3proxyConfig(initialState, runtimePaths), 'utf8');
await runtime.initialize();
const app = createApp({ store, runtime, runtimeRootDir, auth });
app.listen(port, () => {
const liveSync = new LiveSyncServer({ store, runtime, runtimePaths, auth });
await liveSync.initialize();
const app = createApp({ store, runtime, runtimeRootDir, auth, liveSync });
const server = createServer(app);
liveSync.attach(server);
server.listen(port, () => {
console.log(`Panel server listening on http://0.0.0.0:${port}`);
});
}