Lacquered DAEMON_OPTS errors

When using inline C with Varnish, I was unable to get / etc / lnn / default to
be happy at startup.

I tested inline C with varnish for two things: GeoIP detection and Anti-Site-Scraping features.

DAEMON_OPTS always complains, despite the fact that I follow others to show that the work is wonderful.

My problem is that running this command line works:

varnishd -f /etc/varnish/varnish-default.conf -s file,/var/lib/varnish/varnish_storage.bin,512M -T 127.0.0.1:2000 -a 0.0.0.0:8080 -p 'cc_command=exec cc -fpic -shared -Wl,-x -L/usr/include/libmemcached/memcached.h -lmemcached -o %o %s'

But he is mistaken when trying to run default startup scripts:

/ etc / default / lnn has this in it:

DAEMON_OPTS="-a :8080 \
             -T localhost:2000 \
             -f /etc/varnish/varnish-default.conf \
             -s file,/var/lib/varnish/varnish_storage.bin,512M \
             -p 'cc_command=exec cc -fpic -shared -Wl,-x -L/usr/include/libmemcached/memcached.h -lmemcached -o %o %s'"

Error:

# /etc/init.d/varnish start
Starting HTTP accelerator: varnishd failed!
storage_file: filename: /var/lib/varnish/vbox.local/varnish_storage.bin size 512 MB.
Error:
Unknown parameter "'cc_command".

If I try to change the last line to:

-p cc_command='exec cc -fpic -shared -Wl,-x -L/usr/include/libmemcached/memcached.h -lmemcached -o %o %s'"

Now this error:

# /etc/init.d/varnish start
Starting HTTP accelerator: varnishd failed!
storage_file: filename: /var/lib/varnish/vbox.local/varnish_storage.bin size 512 MB.
Error: Unknown storage method "hared"

It tries to interpret '-shared' as -s hared and 'hared' is not a storage type.

GeoIP, Anti-Site-Scrape
, "", .

, , , DAEMON_OPTS.
http://drcarter.info/2010/04/how-fighting-against-scraping-using-varnish-vcl-inline-c-memcached/

Debian DAEMON_OPTS, .

- , ?

!

+5
4

, , , , .

, , , Debian, , Ubuntu 11.04 Debian Squeeze.

/etc/default/varnish, $DAEMON_OPTS, init script. init script /etc/init.d/varnish start_varnishd():

start_varnishd() {
    log_daemon_msg "Starting $DESC" "$NAME"
    output=$(/bin/tempfile -s.varnish)
    if start-stop-daemon \
        --start --quiet --pidfile ${PIDFILE} --exec ${DAEMON} -- \
        -P ${PIDFILE} ${DAEMON_OPTS} > ${output} 2>&1; then
        log_end_msg 0
    else
        log_end_msg 1
        cat $output
        exit 1
    fi
    rm $output
}

, , start-stop-daemon, :

 start_varnishd() {
    log_daemon_msg "Starting $DESC" "$NAME"
    output=$(/bin/tempfile -s.varnish)
+   echo "start-stop-daemon --start --quiet --pidfile ${PIDFILE} --exec ${DAEMON} -- -P ${PIDFILE} ${DAEMON_OPTS} > ${output} 2>&1"
    if start-stop-daemon \
        --start --quiet --pidfile ${PIDFILE} --exec ${DAEMON} -- \
        -P ${PIDFILE} ${DAEMON_OPTS} > ${output} 2>&1; then
        log_end_msg 0

, , STDOUT, . , ! . WTF?

, . , . . bash/dash corner? start-stop-daemon bash , :

start_varnishd() {
    log_daemon_msg "Starting $DESC" "$NAME"
    output=$(/bin/tempfile -s.varnish)
    if bash -c "start-stop-daemon \
        --start --quiet --pidfile ${PIDFILE} --exec ${DAEMON} -- \
        -P ${PIDFILE} ${DAEMON_OPTS} > ${output} 2>&1"; then
        log_end_msg 0
    else
        log_end_msg 1
        cat $output
        exit 1
    fi
    rm $output
}

, , , . /etc/default/varnish:

...
## Alternative 2, Configuration with VCL
#
# Listen on port 6081, administration on localhost:6082, and forward to
# one content server selected by the vcl file, based on the request.  Use a 1GB
# fixed-size cache file.
#
DAEMON_OPTS="-a :6081 \
             -T localhost:6082 \
             -f /etc/varnish/geoip-example.vcl \
             -S /etc/varnish/secret \
             -s malloc,100M \
             -p 'cc_command=exec cc -fpic -shared -Wl,-x -L/usr/include/GeoIP.h -lGeoIP -o %o %s'"
...

, - , script. , , start-stop-daemon $DAEMON_OPTS var dash, .

- :

-p 'cc_command=exec /etc/varnish/compile.sh %o %s'"

compile.sh script :

#!/bin/sh
cc -fpic -shared -Wl,-x -L/usr/include/GeoIP.h -lGeoIP -o $@

, init, ! , .

+9

, script, DAEMON_OPTS, ( ). Fedora (15) ; , "$*" bash /etc/init.d/varnish /etc/init.d/functions daemon().

?

0

, , Varnish Tutorial - Put Larnish 80.

Varnish on Debian varnishd /etc/systemd/system/multi-user.target.wants/varnish.service. /etc/default/varnish - , , init, systemd.

, /etc/systemd/system/multi-user.target.wants/varnish.service, systemctl daemon-reload, .

0
source

You can try: - DAEMON_OPTS = "- a: 8080 \ -T localhost: 2000 \ -f / etc / varnish / varnish-default.conf \ -s file, / var / lib / varnish / varnish_storage.bin, 512M \ - p cc_command = 'exec cc -fpic -shared -Wl, -x -L / usr / include / libmemcached / memcached.h -lmemcached -o% o% s' "

0
source

All Articles