MCPcopy Create free account
hub / github.com/agentforce314/clawcodex / start

Method start

src/server/server.py:187–212  ·  view source on GitHub ↗

Bind both listeners; ``serve_forever`` to actually run.

(self)

Source from the content-addressed store, hash-verified

185 # ─── Public lifecycle ────────────────────────────────────────────
186
187 async def start(self) -> None:
188 """Bind both listeners; ``serve_forever`` to actually run."""
189 # WS listener first so we know its port for the ``ws_url`` we
190 # hand out from the HTTP route.
191 self._ws_server = await ws_serve(
192 self._handle_ws_connection,
193 host=self.config.host or '127.0.0.1',
194 port=0, # ephemeral
195 )
196 ws_sockets = list(self._ws_server.sockets or [])
197 if not ws_sockets:
198 raise RuntimeError('DirectConnectServer: WS listener has no socket')
199 self._ws_port = ws_sockets[0].getsockname()[1]
200
201 # HTTP listener.
202 if self.config.unix:
203 self._http_server = await asyncio.start_unix_server(
204 self._handle_http_connection,
205 path=self.config.unix,
206 )
207 else:
208 self._http_server = await asyncio.start_server(
209 self._handle_http_connection,
210 host=self.config.host or '127.0.0.1',
211 port=self.config.port,
212 )
213
214 async def serve_forever(self) -> None:
215 if self._http_server is None or self._ws_server is None:

Calls

no outgoing calls