diff --git a/openxcap b/openxcap index 2c6872b..7ad17d3 100644 --- a/openxcap +++ b/openxcap @@ -1,67 +1,76 @@ #!/usr/bin/env python # Copyright (C) 2007-2010 AG Projects. # """OpenXCAP""" +MEMORY_DEBUG = False + if __name__ == '__main__': import sys from optparse import OptionParser from application.process import process, ProcessError from application import log import xcap name = 'openxcap' description = 'An open source XCAP Server' version = xcap.__version__ fullname = 'OpenXCAP %s' % version config_directory = '/etc/openxcap' runtime_directory = '/var/run/openxcap' default_pid = "%s/%s.pid" % (runtime_directory, name) parser = OptionParser(version="%%prog %s" % version) parser.add_option("--no-fork", action="store_false", dest="fork", default=1, help="run the process in the foreground (for debugging)") parser.add_option("--pid", dest="pidfile", default=default_pid, help="pid file (%s)" % default_pid, metavar="File") (options, args) = parser.parse_args() try: xcap.dependencies.check() except xcap.DependencyError, e: log.fatal(str(e)) sys.exit(1) pidfile = options.pidfile process.system_config_directory = config_directory if not options.fork: process._runtime_directory = None else: try: process.runtime_directory = runtime_directory process.daemonize(pidfile) except ProcessError, e: log.msg("Fatal error: %s" % e) sys.exit(1) else: from xcap.logutil import start_log start_log() log.msg("Starting %s" % fullname) try: + if not options.fork and MEMORY_DEBUG: + from application.debug.memory import memory_dump from xcap.server import XCAPServer server = XCAPServer() server.start() except Exception, e: log.fatal("failed to create %s: %s" % (fullname, e)) if e.__class__ is not RuntimeError: log.err() sys.exit(1) + if not options.fork and MEMORY_DEBUG: + print "------------------" + memory_dump() + print "------------------" +