systemd and varnish on Ubuntu 16.04

I recently had the opportunity to work on a Ubuntu 16.04 system with systemd and varnish. I’m not a huge fan of systemd as I’m not convinced that it’s solving any problems that I had with SysV init and it makes my work more difficult as it’s not as straight forward.

The problem that I had was getting varnish to listen on a port other than the default of 6081. Ubuntu would traditionally use /etc/default/varnish to make any configuration changes related to startup and that file exists on Ubuntu 16.04 but it is not used. There is a file in /etc/systemd/system/varnish.service that is used to set startup options and can be used to reconfigure the startup ports.

# /etc/systemd/system/varnish.service
...
[Service]
Type=forking
PIDFile=/run/varnishd.pid
LimitNOFILE=131072
LimitMEMLOCK=82000
ExecStart=/usr/sbin/varnishd -a :6081 -T 127.0.0.1:6082 -P /run/varnishd.pid -f /etc/varnish/default.vcl -S /etc/varnish/secret -s file,/var/lib/varnish/varnish_storage.bin,256M
ExecReload=/usr/share/varnish/reload-vcl
...

Once that file has been modified, you then need to issue a systemctl daemon-reload command to get the new settings loaded into systemd.

systemctl daemon-reload

Once that is done, restart varnish using systemctl.

systemctl restart varnish.service

Comments

2 responses to “systemd and varnish on Ubuntu 16.04”

  1. I’m shocked that this is STILL unresolved. I installed Varnish 4, 5 and finally 6 on xenial in attempts to find a properly working version, to no avail.

    Does the bug affect just the listening port in your experience? No other VCL directives are affected, right?

    Thx

  2. Hi RG,

    I haven’t run into any further issues I’ve had to work around here but I do assume it applies to all parameters defined or used in “/etc/systemd/system/varnish.service”.

    Best,
    Josh

Leave a Reply

Your email address will not be published. Required fields are marked *