Add functions to serialize/deserialize backend configs so that Varnish can be safely restarted.
Something like this:
# Write the current backend config to a file
backend_dyn.to_file(VCL_PRIV, "/path/to/backend.cfg");
sub vcl_init {
# Read any previous dynamic config from a file
# This restores any dynamic config that may have been written before Varnish stopped previously
backend_dyn.from_file(VCL_PRIV, "/path/to/backend.cfg");
}
The serialization format may or may not be identical to standard VCL syntax for static backend declarations. If it is, then an initial config can be saved in the file
before initial startup as standard VCL. This would have the advantage that statically declared backend configs could be manipulated by the VMOD after all (it's just that this particular VCL source is not used as the Varnish -f
arg, nor is it included the -f
arg or anything that it includes).