=========================================================================== The Monitor Server =========================================================================== The monitor server gives the developer a way to get into a server while it's running. Here's a quick demonstration of how to get to your server objects while in the monitor: [rushing@gnome medusa]$ python monitor_client.py 127.0.0.1 9999 Enter Password: Python 1.5 (#47, Jul 27 1998, 00:59:35) [GCC egcs-2.90.29 980515 (egcs-1.0.3 release)] Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam Welcome to >>> from __main__ import * >>> dir() ['CHAT_PORT', 'FTP_PORT', 'HOSTNAME', 'HTTP_PORT', 'IP_ADDRESS', 'MONITOR_PORT', 'PUBLISHING_ROOT', '__builtins__', 'asyncore', 'chat_server', 'cs', 'debug_mode', 'default_handler', 'dh', 'filesys', 'fs', 'ftp', 'ftp_server', 'hs', 'http_server', 'lg', 'logger', 'monitor', 'ms', 'os', 'resolver', 'rs', 'sh', 'status_handler', 'status_objects', 'sys', 'uh', 'unix_user_handler'] >>> ms >>> rs >>> hs >>> dir(hs) ['_fileno', 'accept', 'accepting', 'addr', 'bind', 'bytes_in', 'bytes_out', 'close', 'connect', 'connect_ex', 'dup', 'exceptions', 'family_and_type', 'fileno', 'getpeername', 'getsockname', 'getsockopt', 'handlers', 'ip', 'listen', 'logger', 'makefile', 'port', 'recv', 'recvfrom', 'send', 'sendto', 'server_name', 'server_port', 'setblocking', 'setsockopt', 'shutdown', 'socket', 'total_clients', 'total_requests'] >>> hs.total_clients >>> cs >>> cs.close() log: closing channel 9: >>> Use 'exit' or 'Ctrl-D' to close a monitor session. =========================================================================== Emergency Debug Mode =========================================================================== Bugs and memory leaks in long-running servers may take weeks to show up. A useful debugging technique is to leave a crippled or bloated server running, but to move the servers' sockets to different ports so that you can start up another fresh copy in the meanwhile. This allows you to debug the servers without forcing you to leave your site broken while you do it. Here's how: Uncomment the support for '/status/emergency_debug' in When your server goes ballistic, simply hit this URL. This will shut down the servers, and restart them on new ports. Add 10000 to the old port number, so if you were running a web server on port 80, it will be moved to 10080. Start up another copy of your system, which will run on the original ports. Now you can debug the errant servers in isolation. Beats using GDB!