def context_serve(context, configfile, listen_addr, listen_port, logfile,<EOL>debug, daemon, uid, gid, pidfile, umask, rundir):
global global_config<EOL>server = None<EOL>try:<EOL><INDENT>with context:<EOL><INDENT>level = logging.DEBUG if debug else logging.INFO<EOL>init_logging(logfile=logfile, loglevel=level,<EOL>configfile=configfile)<EOL>server = server_from_config()<EOL>logger.info("<STR_LIT>" % server.server_address)<EOL>if debug:<EOL><INDENT>poll_interval = float(global_config.get(<EOL>'<STR_LIT>', '<STR_LIT>'))<EOL>if poll_interval:  <EOL><INDENT>def diagnostic_loop(server):<EOL><INDENT>log = logger<EOL>while True:<EOL><INDENT>log.debug(<EOL>"<STR_LIT>")<EOL>store = server.queue_manager.store<EOL>for dest in store.destinations():<EOL><INDENT>log.debug("<STR_LIT>" % (<EOL>dest, store.size(dest), server.queue_manager.subscriber_count(dest)))<EOL><DEDENT>time.sleep(poll_interval)<EOL><DEDENT><DEDENT>diagnostic_thread = threading.Thread(<EOL>target=diagnostic_loop, name='<STR_LIT>', args=(server,))<EOL>diagnostic_thread.daemon = True<EOL>diagnostic_thread.start()<EOL><DEDENT><DEDENT>server.serve_forever()<EOL><DEDENT><DEDENT>except (KeyboardInterrupt, SystemExit):<EOL><INDENT>logger.info("<STR_LIT>")<EOL>raise SystemExit()<EOL><DEDENT>except Exception as e:<EOL><INDENT>logger.error("<STR_LIT>" % e)<EOL>logger.exception(e)<EOL>raise SystemExit()<EOL><DEDENT>finally:<EOL><INDENT>if server:<EOL><INDENT>server.server_close()<EOL><DEDENT><DEDENT>
Takes a context object, which implements the __enter__/__exit__ "with" interface 
and starts a server within that context.

This method is a refactored single-place for handling the server-run code whether
running in daemon or non-daemon mode.  It is invoked with a dummy (passthrough) 
context object for the non-daemon use case. 

@param options: The compiled collection of options that need to be parsed. 
@type options: C{ConfigParser}

@param context: The context object that implements __enter__/__exit__ "with" methods.
@type context: C{object}

@raise Exception: Any underlying exception will be logged but then re-raised.
@see: server_from_config()