Skip to content
Michael Meisinger edited this page Mar 25, 2015 · 4 revisions

System configuration is stored in files in YAML format. This is an easy to read format based on indentation to show containment in key-value pair structures and lists. Configuration is later accessible within the container.

Configuration Load Order

  1. res/config/pyon.yml
  2. res/config/pyon.local.yml (if provided)
  3. config YML file provided using pycc -c option (if provided)
  4. key=value arguments on pycc command line

Configuration Files

The following is an example res/config/pyon.local.yml file:

system:
  name: mysystem

server:
  postgresql:
    host: localhost
    port: 5432
    username: ion
    password: 12345
    admin_username: admin
    admin_password: 54321
    connection_pool_max: 5      # Number of connections for entire container

container:
  processes:
    log_exceptions: True
  tracer:
    enabled: True

It is important to not leave empty configuration keys within the override file, because otherwise this entry will be set to null and any child entries will be removed. The following is wrong:

container:
  processes:    # BAD BAD BAD - will delete entire container dict and child dicts

Accessing Configuration

The container wide configuration can be accessed as follows:

from pyon.public import CFG
value = CFG.get_safe("my.key.to.config", "default")

Every started container process may have configuration overrides and therefore must access configuration as follows:

value = self.CFG.get_safe("my.key.to.config", "default")}}}

== Logging Configuration

Default logging config is defined in res/config/logging.yml in Python logging config format.

Override configuration can be provided in an res/config/logging.local.yml file, for instance changing logging levels for specific components of interest:

{{{
formatters:
  colors:
    format: '[$BOLD%(asctime)s$RESET %(levelname)-16s %(threadName)s %(name)-10s:%(lineno)3d %(message)s'

handlers:
  console:
    class: putil.clog.ColoredStreamHandler
    formatter: colors
    level: DEBUG
    stream: ext://sys.stdout
    mapping:
      DEBUG: -1
      INFO: 2
      WARNING: 3
      ERROR: 4
      CRITICAL: 5

loggers:
  requests:
    level: WARNING

  ion:
    level: INFO

  pyon:
    level: INFO

  pyon.core.interceptor.validate:
    level: ERROR

  ion.util.preload:
    level: DEBUG

Clone this wiki locally