Replace polling with websocket live sync
This commit is contained in:
@@ -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}`);
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user