dont ignore SIGTERM/SIGINT when already shutting down

This commit is contained in:
Alex Grintsvayg 2017-08-02 15:51:25 -04:00
parent cc5b626a54
commit ddcf3a47f8

View file

@ -8,6 +8,7 @@ import urllib
import json import json
import textwrap import textwrap
import random import random
import signal
from twisted.web import server from twisted.web import server
from twisted.internet import defer, threads, error, reactor from twisted.internet import defer, threads, error, reactor
@ -385,7 +386,15 @@ class Daemon(AuthJSONRPCServer):
except OSError: except OSError:
pass pass
@staticmethod
def _already_shutting_down(sig_num, frame):
log.info("Already shutting down")
def _shutdown(self): def _shutdown(self):
# ignore INT/TERM signals once shutdown has started
signal.signal(signal.SIGINT, self._already_shutting_down)
signal.signal(signal.SIGTERM, self._already_shutting_down)
log.info("Closing lbrynet session") log.info("Closing lbrynet session")
log.info("Status at time of shutdown: " + self.startup_status[0]) log.info("Status at time of shutdown: " + self.startup_status[0])
self.looping_call_manager.shutdown() self.looping_call_manager.shutdown()