Exemplo n.º 1
0
 def start(self):
     """ Do start action. """
     signal.signal(signal.SIGINT, self.on_signal)
     signal.signal(signal.SIGTERM, self.on_signal)
     signal.signal(signal.SIGHUP, self.on_signal)
     self.pre_run()
     if self._config.get("daemon"):
         daemonize()
         run_function = log.log_exceptions(
             logger_name=self.prog,
             re_raise=False)(self.run)
     else:
         run_function = log.log_exceptions(
             logger_name=self.prog,
             re_raise=True)(self.run)
     if self._config.get("pidfile"):
         pid_write(self._config["pidfile"], os.getpid(), excl=True)
     try:
         run_function()
     except:
         self.save_status()
         if self._config.get("pidfile"):
             pid_remove(self._config.get("pidfile"))
         raise sys.exc_info()[1]
     if self._config.get("pidfile"):
         pid_remove(self._config.get("pidfile"))
Exemplo n.º 2
0
 def single(self):
     """ Do single action. """
     if self._config.get("pidfile"):
         pid_write(self._config["pidfile"], os.getpid(), excl=True)
     self.pre_run()
     self.run()
     if self._config.get("pidfile"):
         pid_remove(self._config.get("pidfile"))
Exemplo n.º 3
0
 def clean(self):
     """ Clean before exiting. """
     if self._config.get("pidfile"):
         pid_remove(self._config.get("pidfile"))
Exemplo n.º 4
0
 def clean(self):
     """ Clean before exiting. """
     if self._config.get("pidfile"):
         pid_remove(self._config.get("pidfile"))