Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

custom pidfile causing restart to fail #72

Closed
mgla opened this issue Apr 4, 2017 · 10 comments
Closed

custom pidfile causing restart to fail #72

mgla opened this issue Apr 4, 2017 · 10 comments
Assignees
Labels

Comments

@mgla
Copy link

mgla commented Apr 4, 2017

Steps to reproduce:

Fire up a new Ubuntu 14.04 instance (I used an AWS Ubuntu image):

add-apt-repository "deb https://repo.varnish-cache.org/ubuntu/ trusty varnish-4.1"
apt-get update
apt-get install varnish --force-yes -y
sed -i 's#-s malloc,256m"#-P /run/varnishd.pid \\\n             -s malloc,256m"#' /etc/default/varnish
service varnish restart

Expected behavior

Clean restart

Actual behavior

 * Stopping HTTP accelerator varnishd
No /usr/sbin/varnishd found running; none killed.
   ...fail!
 * Starting HTTP accelerator varnishd
   ...fail!
Error: Cannot open socket: :6081: Address already in use

Additional details:

The sed just adds the -P parameter to /etc/default/varnish:

DAEMON_OPTS="-a :6081 \
             -T localhost:6082 \
             -f /etc/varnish/default.vcl \
             -S /etc/varnish/secret \
             -P /run/varnishd.pid \
             -s malloc,256m"

Took me a while to track it down. I recently opened this report: #71 but was wrong in my assessment.

@mgla
Copy link
Author

mgla commented Apr 4, 2017

Pinging @denisbr I managed to reproduce it, but it was not what I expected.

@denisbr
Copy link
Contributor

denisbr commented Apr 4, 2017

Does the varnish use have sufficient privileges on the /run directory?

@denisbr
Copy link
Contributor

denisbr commented Apr 4, 2017

Also, could you dump the complete resulting /etc/default/varnish?

@mgla
Copy link
Author

mgla commented Apr 4, 2017

Complete /etc/default/varnish:

# Configuration file for Varnish Cache.
#
# /etc/init.d/varnish expects the variables $DAEMON_OPTS, $NFILES and $MEMLOCK
# to be set from this shell script fragment.
#
# Note: If systemd is installed, this file is obsolete and ignored.  You will
# need to copy /lib/systemd/system/varnish.service to /etc/systemd/system/ and
# edit that file.

# Should we start varnishd at boot?  Set to "no" to disable.
START=yes

# Set WARMUP_TIME to force a delay in reload-vcl between vcl.load and vcl.use
# This is useful when backend probe definitions need some time before declaring
# configured backends healthy, to avoid routing traffic to a non-healthy backend.
#WARMUP_TIME=0

# Maximum number of open files (for ulimit -n)
NFILES=131072

# Maximum locked memory size (for ulimit -l)
# Used for locking the shared memory log in memory.  If you increase log size,
# you need to increase this number as well
MEMLOCK=82000

DAEMON_OPTS="-a :6081 \
             -T localhost:6082 \
             -f /etc/varnish/default.vcl \
             -S /etc/varnish/secret \
             -P /run/varnishd.pid \
             -s malloc,256m"


@mgla
Copy link
Author

mgla commented Apr 4, 2017

/run/varnishd.pid is actually the default pid file. @denisbr This might not even be an issue with the packaging. Should I reopen an issue at the varnish repository? https://github.com/varnishcache/varnish-cache

@denisbr denisbr self-assigned this Apr 5, 2017
@denisbr denisbr added the invalid label Apr 5, 2017
@denisbr
Copy link
Contributor

denisbr commented Apr 5, 2017

This is definitely not a varnish-cache issue, and while it is caused by packaging and the initscripts, it's not really a bug per-se.

The issue is that the initscript has it's own pidfile handling:
https://github.com/varnishcache/pkg-varnish-cache/blob/master/debian/varnish.init#L23-L52

If you want to use an alternative pidfile path / filename, the correct way to do this in debian is to add a PIDFILE option to the /etc/default/varnish file.

PIDFILE="/run/mycustompidfile.pid

This will override the predefined PIDFILE in the initscript, and make all interaction with the script work as expected.

@denisbr denisbr closed this as completed Apr 5, 2017
mgla added a commit to mgla/ansible-role-varnish that referenced this issue Apr 5, 2017
@mgla
Copy link
Author

mgla commented Apr 5, 2017

@denisbr Actually, the init script ignores externally set PIDFILE and hardcodes it to /run/varnishd.pid, see /etc/init.d/varnish

Edit 1: I can still reproduce the behavior when I use PIDFILE in /etc/default/varnish, and will investigate. Please do not close the issue just yet.

Edit 2: You are right, nevermind.

@denisbr
Copy link
Contributor

denisbr commented Apr 5, 2017

@mgla I did the work to test all scenarios that I mentioned in local environments before closing.

@mgla
Copy link
Author

mgla commented Apr 5, 2017

@denisbr You were absolutely right. I believieve this can be closed.

@denisbr
Copy link
Contributor

denisbr commented Apr 5, 2017

Thanks for confirming, leaving the issue closed :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants