server.cli ========== .. py:module:: server.cli .. autoapi-nested-parse:: The onegov.server can be run through the 'onegov-server' command after installation. Said command runs the onegov server with the given configuration file in the foreground. Use this **for debugging/development only**. Example:: onegov-server --config-file test.yml The onegov-server will load 'onegov.yml' by default and it will restart when any file in the current folder or any file somewhere inside './src' changes. Changes to omlette directories require a manual restart. A onegov.yml file looks like this: .. code-block:: yaml applications: - path: /apps/* application: my.app.TestApp namespace: apps configuration: allowed_hosts_expression: '^[a-z]+.apps.dev' dsn: postgres://username:password@localhost:5432/db identity_secure: false identity_secret: very-secret-key logging: formatters: simpleFormater: format: '%(asctime)s - %(levelname)s: %(message)s' datefmt: '%Y-%m-%d %H:%M:%S' handlers: console: class: logging.StreamHandler formatter: simpleFormater level: DEBUG stream: ext://sys.stdout loggers: onegov.core: level: DEBUG handlers: [console] Attributes ---------- .. autoapisummary:: server.cli.RESOURCE_TRACKER Classes ------- .. autoapisummary:: server.cli.WSGIRequestMonitorMiddleware server.cli.WsgiProcess server.cli.WsgiServer Functions --------- .. autoapisummary:: server.cli.run server.cli.run_production server.cli.run_debug server.cli.debug_wsgi_factory Module Contents --------------- .. py:data:: RESOURCE_TRACKER :type: onegov.server.tracker.ResourceTracker :value: None .. py:function:: run(config_file: str | bytes, port: int, pdb: bool, tracemalloc: bool, mode: Literal['debug', 'production'], sentry_dsn: str | None, sentry_environment: str, sentry_release: str | None, send_ppi: bool, traces_sample_rate: float, profiles_sample_rate: float) -> None Runs the onegov server with the given configuration file in the foreground. Use this **for debugging/development only**. Example:: onegov-server --config-file test.yml The onegov-server will load 'onegov.yml' by default and it will restart when any file in the current folder or any file somewhere inside './src' changes. Changes to omlette directories require a manual restart. .. py:function:: run_production(config_file: str | bytes, port: int, with_sentry: bool) -> None .. py:function:: run_debug(config_file: str | bytes, port: int, pdb: bool, tracemalloc: bool) -> None .. py:function:: debug_wsgi_factory(config_file: str | bytes, pdb: bool) -> onegov.server.Server .. py:class:: WSGIRequestMonitorMiddleware(app: _typeshed.wsgi.WSGIApplication) Measures the time it takes to respond to a request and prints it at the end of the request. .. py:attribute:: app .. py:method:: __call__(environ: _typeshed.wsgi.WSGIEnvironment, start_response: _typeshed.wsgi.StartResponse) -> collections.abc.Iterable[bytes] .. py:method:: log(environ: _typeshed.wsgi.WSGIEnvironment, status: str, received: float) -> None .. py:class:: WsgiProcess(app_factory: collections.abc.Callable[[], _typeshed.wsgi.WSGIApplication], host: str = '127.0.0.1', port: int = 8080, env: dict[str, str] | None = None, enable_tracemalloc: bool = False) Bases: :py:obj:`multiprocessing.Process` Runs the WSGI reference server in a separate process. This is a debug process, not used in production. .. py:attribute:: _ready :type: multiprocessing.sharedctypes.Synchronized[int] .. py:attribute:: app_factory .. py:attribute:: host :value: '127.0.0.1' .. py:attribute:: port :value: 8080 .. py:attribute:: enable_tracemalloc :value: False .. py:property:: ready :type: bool .. py:method:: print_memory_stats(signum: int, frame: types.FrameType | None) -> None .. py:method:: disable_systemwide_darwin_proxies() .. py:method:: run() -> None Method to be run in sub-process; can be overridden in sub-class .. py:class:: WsgiServer(app_factory: collections.abc.Callable[[], _typeshed.wsgi.WSGIApplication], host: str = '127.0.0.1', port: int = 8080, **kwargs: Any) Bases: :py:obj:`watchdog.events.FileSystemEventHandler` Wraps the WSGI process, providing the ability to restart the process and acting as an event-handler for watchdog. .. py:attribute:: app_factory .. py:attribute:: _host :value: '127.0.0.1' .. py:attribute:: _port :value: 8080 .. py:attribute:: kwargs .. py:method:: spawn() -> WsgiProcess .. py:method:: join(timeout: float | None = None) -> None .. py:method:: start() -> None .. py:method:: restart() -> None .. py:method:: stop(block: bool = False) -> None .. py:method:: on_any_event(event: watchdog.events.FileSystemEvent) -> None If anything of significance changed, restart the process.