“service varnish stop” doesn’t actually stop Varnish

varnish

I'm running Amazon Linux.

I originally installed Varnish 3 on this box, but have now installed Varnish 4.

sudo varnishd -a 0.0.0.0:80 -f /etc/varnish/default.vcl 

…works just fine to start Varnish 4, and

pkill varnishd

…works fine to kill it.

But

service varnish stop

appears to control Varnish 3, and not Varnish 4. I'm very confused!

Why is this? What can I do to help this box forget about Varnish 3?

Best Answer

if you'd like to use service to stop Varnish, you should also use same service to start Varnish as well, and not running it manually like you do.

if you need to update your script, use either whereis or which to find where your binary is, then make sure that your init script points to same place as what you found:

# grep ^exec /etc/init.d/varnish
exec="/usr/sbin/varnishd"
# 

and that's all assuming you're using RHEL6, as for RHEL7 Varnish comes with systemd script:

$ rpm -q varnish
varnish-4.0.3-3.el7.x86_64
$ grep ^ExecStart /usr/lib/systemd/system/varnish.service 
ExecStartPre=/usr/sbin/varnishd -C -f $VARNISH_VCL_CONF
ExecStart=/usr/sbin/varnishd \
$ 

also, unless there is an actual need, i don't think it's good idea to have both of them installed on same system.