Varnishncsa Log

Hi all,

I have been a silent reader for almost 2 years, I've got a lot of knowledge of FreeBSD by reading in this Forum. Thank You, all!

I have a problem that really make me stupid and embarrassed.

I have installed latest Nginx 1.8.0_3,2 and Varnish 4.0.3_7 as a HTTP Accelerator. And for log report, I have activated varnishncsa just because it has simple to read than varnishlog.

Here is my /etc/rc.conf
Code:
varnishncsa_enable="YES"
varnishncsa_pidfile="/var/run/varnishncsa.pid"
varnishncsa_file="/var/log/varnishncsa.log"

Then it comes a problem, I have to manually starting varnishncsa by executing service varnishncsa restart or /usr/local/etc/rc.d/varnishncsa start every time I reboot or starting up my server.

There is something I could not figure out, why varnishncsa did not start according to my rc.conf.
Code:
root@cloud:~ # freebsd-version
10.2-RELEASE-p2
Regards - Ary FR
 
Per /usr/local/etc/rc.d/varnishd startup script
# Add the following line to /etc/rc.conf to enable varnishd:
#
# varnishd_enable="YES"

Read /usr/ports/www/varnish4/files/pkg-message.in for details.
 
Not sure but actual precmd in varnishlog and varnishncsa rc.d script may not work if a stale _.vsm file remains after varnishd stop.

Do you have any error or any trace in your logs about varnishncsa? Maybe a:
Abandoned VSM file (Varnish not running?)

My workaround was to add a sleep 10 in postcmd to varnishd rc.d script:
Code:
# ...
start_postcmd="${name}_poststart"

# ...

varnishd_poststart()
{
    if run_rc_script %%PREFIX%%/etc/rc.d/varnishlog enabled || run_rc_script %%PREFIX%%/etc/rc.d/varnishncsa enabled; then
      sleep 10
    fi

    return 0
}
It's ugly but I don't restart my computer every 5 minutes. Besides, IMO, a postcmd in varnishd script is better than repeating the same precmd in both, varnishlog and varnishncsa, rc.d scripts.

EDIT : since Varnish 4.1.0 (4.1.0_2 - 2015-11-03 - for www/varnish4), where -t option was introduced for varnishlog and varnishncsa, this workaround is no longer needed.
 
Last edited:
Thank you for your respons, cpm & julp!

I am sorry, I did not put the whole of my rc.conf. varnishd exist on my rc.conf.

Code:
hostname="cloud.domain.com"
ifconfig_em0="inet 10.1.2.7 netmask 255.255.255.0"
defaultrouter="10.1.2.1"
ifconfig_em0_ipv6="inet6 accept_rtadv"
sshd_enable="YES"
ntpd_enable="YES"
powerd_enable="YES"
# Set dumpdev to "AUTO" to enable crash dumps, "NO" to disable
dumpdev="NO"
mysql_enable="YES"
nginx_enable="YES"
php_fpm_enable="YES"
varnishd_enable="YES"
varnishd_listen=":80"
varnishd_config="/usr/local/varnish/default.vcl"
varnishd_storage="malloc,1G"
#varnishd_admin=":6082"
varnishncsa_enable="YES"
varnishncsa_pidfile="/var/run/varnishncsa.pid"
varnishncsa_file="/var/log/varnishncsa.log"

Tried to add flags but alas varnishncsa won't start.

Code:
#varnishncsa_flags="-D -P ${varnishncsa_pidfile} -a ${varnishncsa_file}"
or
#varnishncsa_flags="-P ${varnishncsa_pidfile} -D -a"

This is what i found on message.log (it shows several times)

Code:
Aug 27 00:30:56 cloud varnishd[505]: Platform: FreeBSD,10.2-RELEASE,amd64,-smalloc,-smalloc,-hclassic
Aug 27 00:30:57 cloud varnishd[505]: child (507) Started
Aug 27 07:30:57 cloud root: /etc/rc: WARNING: failed to start varnishncsa
Aug 27 00:30:57 cloud varnishd[505]: Child (507) said Child starts

I read Commit History on www/varnish4 freshports, and I guess that it could be something about startup script (varnishncsa startup code solved on Linux) that prevent varnishncsa to start CMIIW.


At the moment, I wrote:

Code:
@reboot     /usr/local/etc/rc.d/varnishncsa start
on my crontab

It is ugly too, but it works....although I feel this is wrong step.

PS: I will try to edit varnishd rc.d based on your config and see how it works
 
Back
Top