{% if varnish_group == 'proxies' %}
{% set VARNISH_LISTEN_PORT=6081 %}
{% else %}
{% set VARNISH_LISTEN_PORT=80 %}
{% endif %}

{% if varnish_group == 'kojipkgs' %}
{% set VARNISH_STORAGE="malloc,48GB" %}
{% elif varnish_group == 's390kojipkgs' %}
{% set VARNISH_STORAGE="file,/var/lib/varnish/varnish_storage.bin,20G" %}
{% elif varnish_group == 'proxies' %}
{% set VARNISH_STORAGE="malloc,1GB -s Transient=malloc,2G" %}
{% else %}
{% set VARNISH_STORAGE="malloc,1GB" %}
{% endif %}

[Unit]
Description=Varnish Cache, a high-performance HTTP accelerator
After=network-online.target

[Service]
Type=simple
ExecStart=/usr/sbin/varnishd -F -a :{{VARNISH_LISTEN_PORT}} -f /etc/varnish/default.vcl -s {{VARNISH_STORAGE}}

# Maximum number of open files (for ulimit -n)
LimitNOFILE=131072

# Locked shared memory - should suffice to lock the shared memory log
# (varnishd -l argument)
# Default log size is 80MB vsl + 1M vsm + header -> 82MB
# unit is bytes
LimitMEMLOCK=85983232

# Enable this to avoid "fork failed" on reload.
TasksMax=infinity

# Maximum size of the corefile.
LimitCORE=infinity
ExecReload=/usr/sbin/varnishreload

[Install]
WantedBy=multi-user.target
