Unable to restart varnish using "service varnish restart"

nish picture nish · Sep 4, 2013 · Viewed 32.4k times · Source

I made changes in "/etc/default/varnish" as well as the vcl file "/etc/varnish/default.vcl" and therefore want to restart varnish.

But I'm unable to figure out what's wrong. Already spent more than an hour lookijng into it but no luck. Following are the details:

nish@styx:~$ sudo service varnish restart
[sudo] password for nish: 
 * Stopping HTTP accelerator varnishd                                    [fail] 
 * Starting HTTP accelerator varnishd                                    [fail] 
Too many arguments (\...)
usage: varnishd [options]
-a address:port              # HTTP listen address and port
-b address:port              # backend address and port
                             #    -b <hostname_or_IP>
                             #    -b '<hostname_or_IP>:<port_or_service>'
-C                           # print VCL code compiled to C language
-d                           # debug
-f file                      # VCL script
-F                           # Run in foreground
-h kind[,hashoptions]        # Hash specification
                             #   -h critbit [default]
                             #   -h simple_list
                             #   -h classic
                             #   -h classic,<buckets>
-i identity                  # Identity of varnish instance
-l shl,free,fill             # Size of shared memory file
                             #   shl: space for SHL records [80m]
                             #   free: space for other allocations [1m]
                             #   fill: prefill new file [+]
-M address:port              # Reverse CLI destination.
-n dir                       # varnishd working directory
-P file                      # PID file
-p param=value               # set parameter
-s kind[,storageoptions]     # Backend storage specification
                             #   -s malloc
                             #   -s file  [default: use /tmp]
                             #   -s file,<dir_or_file>
                             #   -s file,<dir_or_file>,<size>
                             #   -s persist{experimenta}
                             #   -s file,<dir_or_file>,<size>,<granularity>
-t                           # Default TTL
-S secret-file               # Secret file for CLI authentication
-T address:port              # Telnet listen address and port
-V                           # version
-w int[,int[,int]]           # Number of worker threads
                             #   -w <fixed_count>
                             #   -w min,max
                             #   -w min,max,timeout [default: -w2,500,300]
-u user                      # Priviledge separation user id

Answer

nish picture nish · Sep 4, 2013

Fixed the problem by removing line breaks from the "/etc/default/varnish" file.

DAEMON_OPTS="-a :80 \
             -T localhost:1234 \
             -f /etc/varnish/default.vcl \ 
             -s malloc,256m"

to

DAEMON_OPTS="-a :80 -T localhost:1234 -f /etc/varnish/default.vcl -s malloc,256m"