Squid_ The Definitive Guide - Duane Wessels [34]
% squid -k shutdown
This command sends the TERM signal to the running Squid process. Upon receipt of the TERM signal, Squid closes its incoming sockets so that new requests aren't accepted. It then waits some amount of time for outstanding requests to complete. The default is 30 seconds, which you can change with the shutdown_lifetime directive.
If, for some reason, the squid.pid file is missing or unreadable, the squid -k commands don't work. In this case, you can manually kill Squid by finding the process ID with ps. For example:
% ps ax | grep squid
If you see more than one Squid process, be sure to kill the one that shows up as (squid). For example:
% ps ax | grep squid
294 ?? Is 0:00.01 squid -sD
296 ?? S 0:00.27 (squid) -sD (squid)
% kill -TERM 296
After sending the TERM signal, you may want to watch the log file to double-check that Squid is shutting down:
% tail -f logs/cache.log
2003/09/29 21:49:30| Preparing for shutdown after 9316 requests
2003/09/29 21:49:30| Waiting 10 seconds for active connections to finish
2003/09/29 21:49:30| FD 11 Closing HTTP connection
2003/09/29 21:49:31| Shutting down...
2003/09/29 21:49:31| FD 12 Closing ICP connection
2003/09/29 21:49:31| Closing unlinkd pipe on FD 9
2003/09/29 21:49:31| storeDirWriteCleanLogs: Starting...
2003/09/29 21:49:32| Finished. Wrote 253 entries.
2003/09/29 21:49:32| Took 0.1 seconds (1957.6 entries/sec).
2003/09/29 21:49:32| Squid Cache (Version 2.5.STABLE4): Exiting normally.
If you use squid -k interrupt, Squid shuts down immediately, without waiting for active requests to complete. This is equivalent to sending the INT signal with kill.
Reconfiguring a Running Squid Process
As you learn more about Squid, you'll probably find yourself making many changes to the squid.conf file. To have the new settings take effect, you can either shut down and restart Squid, or you can reconfigure Squid while it is running.
The best way to reconfigure a running Squid process is with the squid -k reconfigure command:
% squid -k reconfigure
When you run this command, a HUP signal is sent to the running Squid process. Squid then reads and parses the squid.conf file. If the operation is successful, you'll see this in cache.log:
2003/09/29 22:02:25| Restarting Squid Cache (version 2.5.STABLE4)...
2003/09/29 22:02:25| FD 12 Closing HTTP connection
2003/09/29 22:02:25| FD 13 Closing ICP connection
2003/09/29 22:02:25| Cache dir '/usr/local/squid/var/cache' size remains unchanged
at 102400 KB
2003/09/29 22:02:25| DNS Socket created on FD 5
2003/09/29 22:02:25| Adding nameserver 10.0.0.1 from /etc/resolv.conf
2003/09/29 22:02:25| Accepting HTTP connections at 0.0.0.0, port 3128, FD 9.
2003/09/29 22:02:25| Accepting ICP messages at 0.0.0.0, port 3130, FD 11.
2003/09/29 22:02:25| WCCP Disabled.
2003/09/29 22:02:25| Loaded Icons.
2003/09/29 22:02:25| Ready to serve requests.
You need to be a little careful with the reconfigure option because it's possible to make changes that cause a fatal error. For example, note that Squid closes and reopens the incoming HTTP and ICP sockets. If you change the http_port to a port number that Squid can't open, it exits with a fatal error message.
Certain options and directives can't be changed while Squid is running. This includes:
Removal of cache directories (cache_dir directive).
Changes to the store_log directive.
Changing the block-size value for coss cache_dirs. In fact, whenever you change this value, you must reinitialize the coss cache_dir.
The coredump_dir directive isn't examined during the reconfigure procedure. Thus, you can't make Squid change its current directory after it has started.
Solaris users may experience a subtle problem when reconfiguring Squid. The fopen( ) call in the Solaris stdio implementation requires an unused file descriptor less than 256. The FILE structure stores the file descriptor as an 8-bit value. Normally this isn't a problem because Squid uses raw I/O (e.g., open( )) to open cache files. However, certain tasks