summaryrefslogtreecommitdiffstats
path: root/roles/anitya/fedmsg/templates/base.py.j2
blob: 9f24fecd06bfca40266a91bbb6eecd74d796d1db (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
config = dict(
    topic_prefix="{{ fedmsg_prefix }}",
    environment="{{ fedmsg_env }}",

    # This used to be set to 1 for safety, but it turns out it was
    # excessive.  It is the number of seconds that fedmsg should sleep
    # after it has initialized, but before it begins to try and send any
    # messages.  If set to a non-zero value, this will slow down one-off
    # fedmsg scripts like the git post-receive hook and pkgdb2branch.
    # If we are experiencing message-loss problems, one of the first things
    # to try should be to turn this number up to a non-zero value.  '1' should
    # be more than sufficient.
    post_init_sleep=0.4,

    # This is the number of milliseconds to wait before timing out on
    # connections.. notably to the fedmsg-relay in the event that it has
    # crashed.
    zmq_linger=2000,

    # Default is 0
    high_water_mark=0,
    io_threads=1,

    # We almost always want the fedmsg-hub to be sending messages with zmq as
    # opposed to amqp or stomp.  The only exception will be the bugzilla
    # amqp<->zmq bridge service.
    zmq_enabled=True,

    # When subscribing to messages, we want to allow splats ('*') so we tell the
    # hub to not be strict when comparing messages topics to subscription
    # topics.
    zmq_strict=False,

    # See the following
    #   - http://tldp.org/HOWTO/TCP-Keepalive-HOWTO/overview.html
    #   - http://api.zeromq.org/3-2:zmq-setsockopt
    zmq_tcp_keepalive=1,
    zmq_tcp_keepalive_cnt=3,
    zmq_tcp_keepalive_idle=60,
    zmq_tcp_keepalive_intvl=5,
)

# 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