Bind the server to the specified address. Args: address (str): The ZMQ address to bind the client-facing socket.
(self, address: str = "tcp://*:5555")
| 89 | self.shutdown() |
| 90 | |
| 91 | def bind(self, address: str = "tcp://*:5555") -> None: |
| 92 | """ |
| 93 | Bind the server to the specified address. |
| 94 | |
| 95 | Args: |
| 96 | address (str): The ZMQ address to bind the client-facing socket. |
| 97 | """ |
| 98 | self._address = address |
| 99 | |
| 100 | # Check if PAIR mode is enabled via environment variable |
| 101 | use_pair_mode = os.environ.get('TLLM_LLMAPI_ZMQ_PAIR', '0') != '0' |
| 102 | socket_type = zmq.PAIR if use_pair_mode else zmq.ROUTER |
| 103 | |
| 104 | if use_pair_mode: |
| 105 | logger_debug( |
| 106 | "[server] Using zmq.PAIR socket type for RPC communication") |
| 107 | |
| 108 | self._client_socket = ZeroMqQueue(address=(address, self._hmac_key), |
| 109 | is_server=True, |
| 110 | is_async=True, |
| 111 | use_hmac_encryption=self._hmac_key |
| 112 | is not None, |
| 113 | socket_type=socket_type, |
| 114 | name="rpc_server") |
| 115 | logger.info(f"RPCServer is bound to {self._address}") |
| 116 | |
| 117 | def shutdown(self, is_remote_call: bool = False) -> None: |
| 118 | """Internal method to trigger server shutdown. |