[Service]
{% if fedmsg_hub_memory_limit_mb|int %}
# Limit max RAM usage for fedmsg-hub.  Also don't let fedmsg-hub use
# more that half of swap available in the system, so that we don't get
# Nagios alerts about low swap.  We would rather have fedmsg-hub OOM
# and be auto-restarted.
{% if ansible_distribution_major_version|int > 7 %}
MemorySwapMax={{ (ansible_memory_mb.swap.total / 2) | int }}M
MemoryMax={{fedmsg_hub_memory_limit_mb}}M
{% else %}
MemoryLimit={{fedmsg_hub_memory_limit_mb}}M
LimitAS={{ (fedmsg_hub_memory_limit_mb|int + (ansible_memory_mb.swap.total / 2)) | int }}M
{% endif %}
{% endif %}

LimitNOFILE=16384

{% if fedmsg_hub_auto_restart %}
Restart=on-failure
{% if env == 'staging' %}
RestartSec=600
{% else %}
RestartSec=10
{% endif %}
{% endif %}
