Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

Every time I attempt to add an extra back end into our VCL file, it's fails.

Here is the DAEMON_OPTS we are running off:

DAEMON_OPTS="-a :80 \ -T localhost:6082 \ -f /etc/varnish/custom.vcl \ -u varnish -g varnish \ -S /etc/varnish/secret \ -s malloc,10G"

And here is the offending backend(s)

backend b1 { .host = "114.123.456.789"; .port = "8080"; }

backend b2 { .host = "203.123.456.789"; .port = "80"; }

Any Ideas ? Gut feeling is it might need the backends to be set somewhere, but I'm not sure where.

Solved

So, it turns out I needed to set the backends in the vcl script, further down in the vcl file (vcl_recv). If this helps anyone else, this is the code that I copied from (https://www.varnish-cache.org/trac/wiki/VCLExampleRestarts)

sub vcl_recv {
            if (req.restarts == 0) {
                    set req.backend = b1;
            } else if (req.restarts == 1) {
                    set req.backend = b2;
            }
}
share|improve this question
1  
Can you clarify what the failure looks like? Does Varnish start with the problem config in place, or fail to start? If it's failing, what's logged? –  Shane Madden Sep 11 '12 at 15:10
    
Varnish is failing to start at all. Have to revert back to a vcl with one backend to get it to restart. I'll see if there's anything in the logs now. –  Peter Griffin Sep 11 '12 at 15:17
    
Actually, the best place to look for errors during start is the binary's output. Your init script is probably sending stdout and stderr to /dev/null - temporarily tweak that to allow that output to be displayed, then try to start the service again? –  Shane Madden Sep 11 '12 at 15:28
    
looked into varnish's own logs and /var/messages and couldn't find anything out the the ordinary. –  Peter Griffin Sep 11 '12 at 15:41
    
Right, you need to look at the output from the service start, not the logs. See my previous message. –  Shane Madden Sep 11 '12 at 15:47

1 Answer 1

So, it turns out I needed to set the backends in the vcl script, further down. If this helps anyone else, this is the code that I copied from (https://www.varnish-cache.org/trac/wiki/VCLExampleRestarts)

sub vcl_recv {
            if (req.restarts == 0) {
                    set req.backend = b1;
            } else if (req.restarts == 1) {
                    set req.backend = b2;
            } else {
                    set req.backend = b3;
            }
}

Bizarre, but true

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.