I would like to add varnishlog logging to this buildpack: https://github.com/chregu/cf-varnish-buildpack
How can I add a second process to be started when the buildpack starts to log Varnish errors to disk/stderr?
The buildpack can spawn background processes. In the case of the buildpack you pointed to, the bin/release
file indicates that it's going to launch boot.sh
on startup. So you can just modify boot.sh
to start whatever you want in the background with the usual shell syntax of adding &
to the command. E.g.:
export APP_ROOT=$HOME
export LD_LIBRARY_PATH=$APP_ROOT/varnish/lib:$LD_LIBRARY_PATH
if [ -z "$VARNISH_MEMORY_LIMIT" ]; then
VARNISH_MEMORY_LIMIT=$MEMORY_LIMIT
fi
# Start some logging process in the background
start_my_logging.sh &
# check varnish config
$APP_ROOT/varnish/sbin/varnishd -C -f $APP_ROOT/varnish/etc/varnish/default.vcl 2>&1
# TODO, Make MEMORY_LIMIT adjustable, this now comes from CF itself
exec $APP_ROOT/varnish/sbin/varnishd -n /home/vcap/tmp/varnish -F -f $APP_ROOT/varnish/etc/varnish/default.vcl -a 0.0.0.0:$VCAP_APP_PORT -t 120 -w 50,1000,120 -s malloc,$VARNISH_MEMORY_LIMIT -T 127.0.0.1:6082 -p http_resp_hdr_len=32768 2>&1
# ------------------------------------------------------------------------------------------------