if options.verify: sys.exit(0) if options.core_dumps: cwd = options.core_dumps else: cwd = "/" if options.daemon: util.daemonize(options.pidfile, cwd) else: os.chdir(cwd) # redirect stdio to log log.init_stdio() def main(): """Start up NagCat, profiling things as requested""" options = parse_options() if options.profile_init or options.profile_run: import cProfile profiler = cProfile.Profile() if options.profile_init: profiler.runcall(init, options) else: init(options)
def main(): options, method = parse_options() log.init(options.logfile, options.loglevel) if not options.dump and options.daemonize: if os.fork() > 0: os._exit(0) os.chdir("/") os.setsid() if os.fork() > 0: os._exit(0) log.init_stdio() try: config = coil.parse(DEFAULT_CONFIG) if method.defaults: if isinstance(method.defaults, str): config.merge(coil.parse(method.defaults)) else: config.merge(coil.struct.Struct(method.defaults)) if options.config: config.merge(coil.parse_file(options.config)) except coil.errors.CoilError, ex: log.error("Error parsing config: %s" % ex) sys.exit(1)