server.cli

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:

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

RESOURCE_TRACKER

Classes

WSGIRequestMonitorMiddleware

Measures the time it takes to respond to a request and prints it

WsgiProcess

Runs the WSGI reference server in a separate process. This is a debug

WsgiServer

Wraps the WSGI process, providing the ability to restart the process

Functions

run(→ None)

Runs the onegov server with the given configuration file in the

run_production(→ None)

run_debug(→ None)

debug_wsgi_factory(→ onegov.server.Server)

Module Contents

server.cli.RESOURCE_TRACKER: onegov.server.tracker.ResourceTracker = None[source]
server.cli.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[source]

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.

server.cli.run_production(config_file: str | bytes, port: int, with_sentry: bool) None[source]
server.cli.run_debug(config_file: str | bytes, port: int, pdb: bool, tracemalloc: bool) None[source]
server.cli.debug_wsgi_factory(config_file: str | bytes, pdb: bool) onegov.server.Server[source]
class server.cli.WSGIRequestMonitorMiddleware(app: _typeshed.wsgi.WSGIApplication)[source]

Measures the time it takes to respond to a request and prints it at the end of the request.

app[source]
__call__(environ: _typeshed.wsgi.WSGIEnvironment, start_response: _typeshed.wsgi.StartResponse) Iterable[bytes][source]
log(environ: _typeshed.wsgi.WSGIEnvironment, status: str, received: float) None[source]
class server.cli.WsgiProcess(app_factory: Callable[[], WSGIApplication], host: str = '127.0.0.1', port: int = 8080, env: dict[str, str] | None = None, enable_tracemalloc: bool = False)[source]

Bases: multiprocessing.Process

Runs the WSGI reference server in a separate process. This is a debug process, not used in production.

_ready: Synchronized[int][source]
app_factory[source]
host = '127.0.0.1'[source]
port = 8080[source]
enable_tracemalloc = False[source]
property ready: bool[source]
print_memory_stats(signum: int, frame: FrameType | None) None[source]
disable_systemwide_darwin_proxies()[source]
run() None[source]

Method to be run in sub-process; can be overridden in sub-class

class server.cli.WsgiServer(app_factory: Callable[[], WSGIApplication], host: str = '127.0.0.1', port: int = 8080, **kwargs: Any)[source]

Bases: watchdog.events.FileSystemEventHandler

Wraps the WSGI process, providing the ability to restart the process and acting as an event-handler for watchdog.

app_factory[source]
_host = '127.0.0.1'[source]
_port = 8080[source]
kwargs[source]
spawn() WsgiProcess[source]
join(timeout: float | None = None) None[source]
start() None[source]
restart() None[source]
stop(block: bool = False) None[source]
on_any_event(event: watchdog.events.FileSystemEvent) None[source]

If anything of significance changed, restart the process.