Exemplo n.º 1
0
 def handleRequest(self):
     try:
         value = self.processRequest()
         self._startResponse(self.status, self.headers)
         return value
     except BadRequest:
         log.log_exc()
         log.notice("Environ: %s" % repr(self.environ))
         self._startResponse("400 Bad Request", [('Content-Type', 'text/html; charset=utf-8')])
         return "<h1>Requête incorrecte</h1><p>L'équipe technique a été informée du problème, veuillez renouveler l'opération dans quelques minutes.</p>"
     except:
         log.log_exc()
         log.notice("Environ: %s" % repr(self.environ))
         self._startResponse("500 Internal Server Error", [('Content-Type', 'text/html; charset=utf-8')])
         return "<h1>Erreur du serveur</h1><p>L'équipe technique a été informée du problème, veuillez renouveler l'opération dans quelques minutes.</p>"
Exemplo n.º 2
0
 def run(self):
     self.service._server = None # do not re-use "forked" session
     signal.signal(signal.SIGINT, signal.SIG_IGN)
     signal.signal(signal.SIGHUP, signal.SIG_IGN)
     signal.signal(signal.SIGTERM, lambda *args: sys.exit(0))
     with _log.log_exc(self.log):
         self.main()
Exemplo n.º 3
0
    def start(self):
        for sig in (signal.SIGTERM, signal.SIGINT):
            signal.signal(sig, lambda *args: sys.exit(-sig))
        signal.signal(signal.SIGHUP, signal.SIG_IGN) # XXX long term, reload config?

        self.log.info('starting %s', self.logname or self.name)
        with _log.log_exc(self.log):
            if getattr(self.options, 'service', True): # do not run-as-service (eg backup)
                _daemonize(self.main, options=self.options, log=self.log, config=self.config, service=self)
            else:
                _daemon_helper(self.main, self, self.log)
Exemplo n.º 4
0
 def run(self):
     signal.signal(signal.SIGINT, signal.SIG_IGN)
     signal.signal(signal.SIGHUP, signal.SIG_IGN)
     signal.signal(signal.SIGTERM, lambda *args: sys.exit(0))
     with _log.log_exc(self.log):
         self.main()