[Unit] Description=Squid web caching proxy After=syslog.target network.target network-online.target nss-lookup.target [Service] Environment="SQUID_CONF=/etc/squid/squid.conf" Environment="SQUID_OPTS=-Y" LimitNOFILE=16384 ExecStartPre=/usr/sbin/squid -N -z -f ${SQUID_CONF} ExecStart=/usr/sbin/squid -N $SQUID_OPTS -f ${SQUID_CONF} ExecReload=/usr/sbin/squid -k reconfigure -f ${SQUID_CONF} # Note: Do NOT use ExecStop=/usr/sbin/squid -k shutdown -f ${SQUID_CONF} # because it doesn't wait for squid to exit, causing systemd to SIGKILL squid # right away which is certainly NOT what we want. # Instead, enjoy the SIGTERM default which is identical to "squid -k shutdown" # but without the nasty side effect of a (too early) SIGKILL. # # However per default, squid takes 30 seconds to exit which is acceptable but # quite a long time. Fortunately, this can easily be changed to 1 second in # /etc/squid/squid.conf: shutdown_lifetime 1 second [Install] WantedBy=multi-user.target