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"))
Example #2
0
 def _initialize_daemon(self):
     """ Initialize daemon. """
     if not self._config.get("daemon"):
         self.work = log.log_exceptions(logger_name=self.prog,
                                        re_raise=True)(self.work)
         return
     daemonize()
     self.work = log.log_exceptions(logger_name=self.prog,
                                    re_raise=False)(self.work)
     self.logger.debug("daemonized")
Example #3
0
 def _initialize_daemon(self):
     """ Initialize daemon. """
     if not self._config.get("daemon"):
         self.work = log.log_exceptions(
             logger_name=self.prog,
             re_raise=True)(self.work)
         return
     daemonize()
     self.work = log.log_exceptions(
         logger_name=self.prog,
         re_raise=False)(self.work)
     self.logger.debug("daemonized")