def _on_signal_received(self, sig):
# Code below must not block to return to select.select() and catch
# next signals
if sig == _utils.SIGALRM:
self._alarm()
elif sig == signal.SIGTERM:
LOG.info('Caught SIGTERM signal, '
'graceful exiting of service %s' % self.title)
if self.service.graceful_shutdown_timeout > 0:
if os.name == "posix":
signal.alarm(self.service.graceful_shutdown_timeout)
else:
threading.Timer(self.service.graceful_shutdown_timeout,
self._alarm).start()
_utils.spawn(self.service._terminate)
elif sig == _utils.SIGHUP:
_utils.spawn(self.service._reload)
评论列表
文章目录