Properly handle SIGTERM if daemon ran with -d #1060
|
@ -66,7 +66,7 @@ class singleCleaner(threading.Thread, StoppableThread):
|
||||||
# If we are running as a daemon then we are going to fill up the UI
|
# If we are running as a daemon then we are going to fill up the UI
|
||||||
# queue which will never be handled by a UI. We should clear it to
|
# queue which will never be handled by a UI. We should clear it to
|
||||||
# save memory.
|
# save memory.
|
||||||
if BMConfigParser().safeGetBoolean('bitmessagesettings', 'daemon'):
|
if shared.thisapp.daemon:
|
||||||
queues.UISignalQueue.queue.clear()
|
queues.UISignalQueue.queue.clear()
|
||||||
if timeWeLastClearedInventoryAndPubkeysTables < int(time.time()) - 7380:
|
if timeWeLastClearedInventoryAndPubkeysTables < int(time.time()) - 7380:
|
||||||
timeWeLastClearedInventoryAndPubkeysTables = int(time.time())
|
timeWeLastClearedInventoryAndPubkeysTables = int(time.time())
|
||||||
|
|
|
@ -6,7 +6,7 @@ from multiprocessing import current_process
|
||||||
from threading import current_thread, enumerate
|
from threading import current_thread, enumerate
|
||||||
import traceback
|
import traceback
|
||||||
|
|
||||||
from bmconfigparser import BMConfigParser
|
import shared
|
||||||
from debug import logger
|
from debug import logger
|
||||||
import queues
|
import queues
|
||||||
import shutdown
|
import shutdown
|
||||||
|
@ -54,7 +54,7 @@ def signal_handler(signal, frame):
|
||||||
if current_thread().name not in ("PyBitmessage", "MainThread"):
|
if current_thread().name not in ("PyBitmessage", "MainThread"):
|
||||||
return
|
return
|
||||||
logger.error("Got signal %i", signal)
|
logger.error("Got signal %i", signal)
|
||||||
if BMConfigParser().safeGetBoolean('bitmessagesettings', 'daemon'):
|
if shared.thisapp.daemon:
|
||||||
shutdown.doCleanShutdown()
|
shutdown.doCleanShutdown()
|
||||||
else:
|
else:
|
||||||
allThreadTraceback(frame)
|
allThreadTraceback(frame)
|
||||||
|
|
|
@ -3,7 +3,6 @@ import Queue
|
||||||
import threading
|
import threading
|
||||||
import time
|
import time
|
||||||
|
|
||||||
from bmconfigparser import BMConfigParser
|
|
||||||
from debug import logger
|
from debug import logger
|
||||||
from helper_sql import sqlQuery, sqlStoredProcedure
|
from helper_sql import sqlQuery, sqlStoredProcedure
|
||||||
from helper_threading import StoppableThread
|
from helper_threading import StoppableThread
|
||||||
|
@ -60,7 +59,7 @@ def doCleanShutdown():
|
||||||
except Queue.Empty:
|
except Queue.Empty:
|
||||||
break
|
break
|
||||||
|
|
||||||
if BMConfigParser().safeGetBoolean('bitmessagesettings','daemon'):
|
if shared.thisapp.daemon:
|
||||||
logger.info('Clean shutdown complete.')
|
logger.info('Clean shutdown complete.')
|
||||||
shared.thisapp.cleanup()
|
shared.thisapp.cleanup()
|
||||||
os._exit(0)
|
os._exit(0)
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
import os
|
import os
|
||||||
|
|
||||||
from bmconfigparser import BMConfigParser
|
import shared
|
||||||
|
|
||||||
# This is used so that the translateText function can be used when we are in daemon mode and not using any QT functions.
|
# This is used so that the translateText function can be used when we are in daemon mode and not using any QT functions.
|
||||||
class translateClass:
|
class translateClass:
|
||||||
|
@ -17,7 +17,11 @@ def _translate(context, text, disambiguation = None, encoding = None, n = None):
|
||||||
return translateText(context, text, n)
|
return translateText(context, text, n)
|
||||||
|
|
||||||
def translateText(context, text, n = None):
|
def translateText(context, text, n = None):
|
||||||
if not BMConfigParser().safeGetBoolean('bitmessagesettings', 'daemon'):
|
try:
|
||||||
|
is_daemon = shared.thisapp.daemon
|
||||||
|
except AttributeError: # inside the plugin
|
||||||
|
is_daemon = False
|
||||||
|
if not is_daemon:
|
||||||
try:
|
try:
|
||||||
from PyQt4 import QtCore, QtGui
|
from PyQt4 import QtCore, QtGui
|
||||||
except Exception as err:
|
except Exception as err:
|
||||||
|
|
Reference in New Issue
Block a user