After a centos update, varnish did not start anymore. We modified varnish.service and now it works.


« Back to overview

After a centos update, we could not get varnish 4 to work with the usual systemctl start varnish.

Here's a modification of /usr/lib/systemd/system/varnish.service that did the trick for us (We added: RemainAfterExit=yes and modified the type to Type=simple).


[Service]
# If you want to make changes to this file, please copy it to
# /etc/systemd/system/varnish.service and make your changes there.
# This will override the file kept at /lib/systemd/system/varnish.service
#
# Enviroment variables may be found in /etc/varnish/varnish.params
#

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

# Locked shared memory (for ulimit -l)
# Default log size is 82MB + header
LimitMEMLOCK=82000

# On systemd >= 228 enable this to avoid "fork failed" on reload.
#TasksMax=infinity

# Maximum size of the corefile.
LimitCORE=infinity

EnvironmentFile=/etc/varnish/varnish.params

Type=simple
PIDFile=/var/run/varnish.pid
PrivateTmp=true
ExecStart=/usr/sbin/varnishd \
	-P /var/run/varnish.pid \
	-f $VARNISH_VCL_CONF \
	-a ${VARNISH_LISTEN_ADDRESS}:${VARNISH_LISTEN_PORT} \
	-T ${VARNISH_ADMIN_LISTEN_ADDRESS}:${VARNISH_ADMIN_LISTEN_PORT} \
	-S $VARNISH_SECRET_FILE \
	-u $VARNISH_USER -g $VARNISH_GROUP \
	-s $VARNISH_STORAGE \
	$DAEMON_OPTS
RemainAfterExit=yes
ExecReload=/usr/sbin/varnish_reload_vcl

[Install]
WantedBy=multi-user.target