#981802 squid starts too early with systemd

Package:
squid
Source:
squid
Description:
Full featured Web Proxy cache (HTTP proxy GnuTLS flavour)
Submitter:
Rob Janssen
Date:
2021-02-03 23:09:03 UTC
Severity:
normal
#981802#5
Date:
2021-02-03 22:57:42 UTC
From:
To:
Dear Maintainer,

When squid is installed on a buster system with systemd and a DNS resolver, the
squid
proxy appears to be started too early.  I use bind9 as a DNS server/resolver
and have
127.0.0.1 configured in /etc/resolv.conf and in the squid configuration files.
When configuration items like access lists refer to DNS names, the squid proxy
fails
to start on reboot and messages are logged that resolving DNS names failed.
When
the service is then started manually it runs fine.
It appears to be a race condition caused by starting squid too early, when
bind9 is
not yet ready to handle requests.

I am not sufficiently proficient in systemd configuration to properly work
around
this, so I worked around it the crude way by setting:
ExecStartPre=/usr/bin/sleep 10
in the squid.service file.  The ExecStartPre=/usr/sbin/squid --foreground -z
that is there is only required the first time squid is started but I guess
systemd
lacks the capability to only do this when /var/spool/squid has not yet been
populated.