Search code examples
magentovarnishvarnish-vcl

Varnish how to save default.vcl config on restart


We use Turpentine to manage varnish config. Turpentine pushes config to our varnish servers and that config remains in memory. Varnish does not however save the config to it's default.vcl file. If I go on the server varnish is running on, it will use a very old config because it's reading from default.vcl. It's not until I push config from Magento that varnish start operating again.


Solution

  • I would suggest editing your /etc/init.d/varnish as below

    stop_varnishd() {
        log_daemon_msg "Stopping $DESC" "$NAME"
        #save varnish config to default
        varnishadm vcl.show $(varnishadm vcl.list | awk '/^active/ {print $3}') > /etc/varnish/default.vcl
        ...
    

    Basically add a line to the stop function that first saves in-memory config to file so if you're restarting it will pick up latest config on next start.

    This should be part of the default I think.