Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Even if Jacob will probably never read this, visitors from the future might appreciate what I'm going to write.</p> <p>I believe I know what's wrong, and it looks like a Debian-specific problem, at least verified on Ubuntu 11.04 and Debian Squeeze.</p> <p>I traced the execution from my <code>/etc/default/varnish</code> that contains the <code>$DAEMON_OPTS</code> to the init script. In the init script <code>/etc/init.d/varnish</code>, the <code>start_varnishd()</code> function is:</p> <pre> 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 } </pre> <p>So I modified it to print the full <code>start-stop-daemon</code> command line, like:</p> <pre> 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 </pre> <p>So I got a command line echoed on STDOUT, and copied-pasted it into my shell. And, surprise! It worked. <strong>WTF?</strong></p> <p>Repeated again to be sure. Yes, it works. Mmh. Could it be another of those bash/dash corner cases? Let's try feeding the start-stop-daemon command line to <code>bash</code>, and see how it reacts:</p> <pre> 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 } </pre> <p>Yes, <strong>it works just fine</strong>, at least for my case. Here's the relevant part of my <code>/etc/default/varnish</code>:</p> <pre> ... ## 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'" ... </pre> <p>I've seen posts where someone tried to work around this problem by moving the compile command into a separated shell script. Unfortunately that doesn't change the fact that <code>start-stop-daemon</code> is going to pass the <code>$DAEMON_OPTS</code> var through <code>dash</code>, and that will result in mangled options.</p> <p>Would be something along the lines of:</p> <pre> -p 'cc_command=exec /etc/varnish/compile.sh %o %s'" </pre> <p>And then the <code>compile.sh</code> script as:</p> <pre> #!/bin/sh cc -fpic -shared -Wl,-x -L/usr/include/GeoIP.h -lGeoIP -o $@ </pre> <p>but it doesn't work, so just patch your init scripts, and you're good to go! Hope you can find this information useful.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload