Server uses ServiceConfig for web/rpc port default values, configurable through env variables

This commit is contained in:
Mose Müller 2023-12-21 15:26:37 +01:00
parent 2a2b7b800d
commit edb24f5439

View File

@ -12,6 +12,7 @@ from rpyc import ThreadedServer # type: ignore[import-untyped]
from uvicorn.server import HANDLED_SIGNALS from uvicorn.server import HANDLED_SIGNALS
from pydase import DataService from pydase import DataService
from pydase.config import ServiceConfig
from pydase.data_service.data_service_observer import DataServiceObserver from pydase.data_service.data_service_observer import DataServiceObserver
from pydase.data_service.state_manager import StateManager from pydase.data_service.state_manager import StateManager
from pydase.server.web_server import WebServer from pydase.server.web_server import WebServer
@ -85,9 +86,11 @@ class Server:
The host address for the server. Default is '0.0.0.0', which means all The host address for the server. Default is '0.0.0.0', which means all
available network interfaces. available network interfaces.
rpc_port: int rpc_port: int
The port number for the RPC server. Default is 18871. The port number for the RPC server. Default is
`pydase.config.ServiceConfig().rpc_port`.
web_port: int web_port: int
The port number for the web server. Default is 8001. The port number for the web server. Default is
`pydase.config.ServiceConfig().web_port`.
enable_rpc: bool enable_rpc: bool
Whether to enable the RPC server. Default is True. Whether to enable the RPC server. Default is True.
enable_web: bool enable_web: bool
@ -151,8 +154,8 @@ class Server:
self, self,
service: DataService, service: DataService,
host: str = "0.0.0.0", host: str = "0.0.0.0",
rpc_port: int = 18871, rpc_port: int = ServiceConfig().rpc_port,
web_port: int = 8001, web_port: int = ServiceConfig().web_port,
enable_rpc: bool = True, enable_rpc: bool = True,
enable_web: bool = True, enable_web: bool = True,
filename: str | Path | None = None, filename: str | Path | None = None,