예제 #1
0
파일: bootstrap.py 프로젝트: pepribas/F3AT
 def __enter__(self):
     log.FluLogKeeper.init()
     self._parse_opts()
     if self.opts.debug:
         log.FluLogKeeper.set_debug(self.opts.debug)
     if self.opts.agency_daemonize:
         tmp = tempfile.mktemp(suffix="feat.temp.log")
         run.daemonize(stdout=tmp, stderr=tmp)
     self.agency = self._run_agency()
     return self
예제 #2
0
파일: bootstrap.py 프로젝트: zaheerm/feat
 def __exit__(self, type, value, traceback):
     if type is not None:
         raise type(value), None, traceback
     if self.opts.agency_daemonize:
         tmp = tempfile.mktemp(suffix="feat.temp.log")
         log.info("run", "Logging will temporarily be done to: %s", tmp)
         run.daemonize(stdout=tmp, stderr=tmp)
         # dump all the log entries logged so far to the FluLogKeeper again
         # the reason for this is that we want them to be included in text
         # file (so far they have been printed to the console)
         tee = log.get_default()
         buff = tee.get_keeper('buffer')
         flulog = tee.get_keeper('flulog')
         buff.dump(flulog)
     # use the resolver from twisted.names instead of the default
     # the reason for this is that ThreadedResolver behaves strangely
     # after the reconnection - raises the DNSLookupError for names
     # which have been resolved while there was no connection
     resolver.installResolver(reactor)
     reactor.run()
예제 #3
0
파일: dummy_process.py 프로젝트: f3at/feat
                      help="should deamonize")
    return parser


def sigusr1_handler(_signum, _frame):
    sys.exit(0)


if __name__ == '__main__':
    log.init()
    parser = _create_parser()
    opt, args = parser.parse_args()
    if opt.fail:
        raise CustomException("I'm failing as you have asked.")
    if opt.daemonize:
        logfile = "dummy.log"
        run.daemonize(stdout=logfile, stderr=logfile)

    signal.signal(signal.SIGUSR1, sigusr1_handler)

    rundir = os.path.curdir
    pid_file = run.acquire_pidfile(rundir, "dummy_process")
    path = run.write_pidfile(rundir, file=pid_file)
    print "Written pid file to %s" % (path, )

    try:
        while True:
            pass
    except KeyboardInterrupt:
        pass