config = {
    # Tell fedmsg-gateway where its special outgoing port is.  haproxy will
    # locally connect back to us here
    'fedmsg.consumers.gateway.port': 9942,

    # Set this number to near, but not quite the fs.file-limit.  Try 160000.
    'fedmsg.consumers.gateway.high_water_mark': 160000,

    # Here is the addres of the master gateway on busgateway01.  We'll get all
    # our messages from here and forward them out fedmsg.consumers.gateway.port
    'endpoints': {
        'fedmsg-gateway-master': [
            'tcp://busgateway01:9940',
        ],
    }

}

# This option adds an IPC socket by which we can monitor hub health.
try:
    import os
    import psutil

    pid = os.getpid()
    proc = [p for p in psutil.process_iter() if p.pid == pid][0]

    # proc.name is a method on modern versions of psutil.
    name = proc.name
    if callable(name):
        name = name()

    config['moksha.monitoring.socket'] = \
        'ipc:///var/run/fedmsg/monitoring-%s.socket' % name
    config['moksha.monitoring.socket.mode'] = '770'
except (OSError, ImportError):
    # We run into issues when trying to import psutil from mod_wsgi on rhel7
    # but this feature is of no concern in that context, so just fail quietly.
    # https://github.com/jmflinuxtx/kerneltest-harness/pull/17#issuecomment-48007837
    pass
