def saygoodbye(): pidlocked = util.read_pidlock(cf.get('honcheonui/pid_file')) if os.getpid() == int(pidlocked): log.debug("same pid(%s). remove pidlock" % pidlocked) os.unlink(cf.get('honcheonui/pid_file')) log.info("bye...") return
cf.set('honcheonui/name', 'honcheonui-%s' % NAME) cf.set('honcheonui/version', VERSION) log.set_level(cf.get('honcheonui/loglevel')) log.info('%s configured properly...' % cf.get('honcheonui/name')) # FIXME reachable test required! if cf.get('master/host') == '': log.fatal("server not configured properly.", os.EX_CONFIG) ### go background! ------------------------------------------------------ if options.debug != True: util.backgroud() if os.path.exists(cf.get('honcheonui/pid_file')): pid = util.read_pidlock(cf.get('honcheonui/pid_file')) log.info("another agent is running maybe. check pid %s." % pid) if options.force == True: log.info("execution forced. kill other and run!") if util.doublekill(int(pid)): log.debug("ok, double kill return exception.") log.debug("- %s maybe killed." % pid) else: log.fatal("execution aborted. use --force for ignore it.") util.write_pidlock(cf.get('honcheonui/pid_file')) log.info("%s[%d] started..." % (NAME, os.getpid())) # yes, about to do my job! import signal, atexit signal.signal(signal.SIGHUP, sighandler)