def main(): (opts, args) = getopts() if chkopts(opts) is True: return PROCERROR cf = readconf(opts.config) if cf is None: print >>sys.stderr, 'Failed to load the config file "%s". (%s)' % (opts.config, sys.argv[0]) return PROCERROR # conf parse if parse_conf(cf) is False: return PROCERROR if reload_conf(cf["env.sys.log.conf.path"]): logger = logging.getLogger('pysilhouette.scheduler') else: print >>sys.stderr, 'Failed to load the log file. (%s)' % sys.argv[0] return PROCERROR try: try: signal.signal(signal.SIGTERM, sigterm_handler) scheduler = Scheduler(opts, cf) ret = scheduler.process() # start!! return ret except KeyboardInterrupt, k: logger.critical('Keyboard interrupt occurred. - %s' % str(k.args)) print >>sys.stderr, 'Keyboard interrupt occurred. - %s' % str(k.args) except Exception, e: logger.critical('A system error has occurred. - %s' % str(e.args)) print >>sys.stderr, 'A system error has occurred. - %s' % str(e.args) print >>sys.stderr, traceback.format_exc() t_logger = logging.getLogger('pysilhouette_traceback') t_logger.critical(traceback.format_exc())
return PROCERROR #### try: opts.config = os.path.abspath(opts.config) except AttributeError, e: print >>sys.stderr, 'No configuration file path.' return PROCERROR cf = readconf(opts.config) if cf is None: print >>sys.stderr, 'Failed to load the config file "%s". (%s)' % (opts.config, sys.argv[0]) return PROCERROR # conf parse if parse_conf(cf) is False: return PROCERROR if reload_conf(cf["env.sys.log.conf.path"]): logger = logging.getLogger('pysilhouette.silhouette') else: print >>sys.stderr, 'Failed to load the log file. (%s)' % sys.argv[0] return PROCERROR if opts.uniqkey: print >>sys.stdout, cf["env.uniqkey"] return PROCSUCCESS if opts.daemon is True: logger.debug('Daemon stdin=%s' % cf['daemon.stdin']) logger.debug('Daemon stdout=%s' % cf['daemon.stdout'])