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
Leave a Reply