Merge pull request #377 from merlink01/master
Changed start code for deamon mode
This commit is contained in:
commit
741e27eb85
|
@ -770,77 +770,101 @@ if shared.useVeryEasyProofOfWorkForTesting:
|
||||||
shared.networkDefaultPayloadLengthExtraBytes = int(
|
shared.networkDefaultPayloadLengthExtraBytes = int(
|
||||||
shared.networkDefaultPayloadLengthExtraBytes / 7000)
|
shared.networkDefaultPayloadLengthExtraBytes / 7000)
|
||||||
|
|
||||||
if __name__ == "__main__":
|
class Main:
|
||||||
# is the application already running? If yes then exit.
|
def start(self, deamon=False):
|
||||||
thisapp = singleton.singleinstance()
|
# is the application already running? If yes then exit.
|
||||||
|
thisapp = singleton.singleinstance()
|
||||||
|
|
||||||
signal.signal(signal.SIGINT, helper_generic.signal_handler)
|
signal.signal(signal.SIGINT, helper_generic.signal_handler)
|
||||||
# signal.signal(signal.SIGINT, signal.SIG_DFL)
|
# signal.signal(signal.SIGINT, signal.SIG_DFL)
|
||||||
|
|
||||||
helper_bootstrap.knownNodes()
|
helper_bootstrap.knownNodes()
|
||||||
# Start the address generation thread
|
# Start the address generation thread
|
||||||
addressGeneratorThread = addressGenerator()
|
addressGeneratorThread = addressGenerator()
|
||||||
addressGeneratorThread.daemon = True # close the main program even if there are threads left
|
addressGeneratorThread.daemon = True # close the main program even if there are threads left
|
||||||
addressGeneratorThread.start()
|
addressGeneratorThread.start()
|
||||||
|
|
||||||
# Start the thread that calculates POWs
|
# Start the thread that calculates POWs
|
||||||
singleWorkerThread = singleWorker()
|
singleWorkerThread = singleWorker()
|
||||||
singleWorkerThread.daemon = True # close the main program even if there are threads left
|
singleWorkerThread.daemon = True # close the main program even if there are threads left
|
||||||
singleWorkerThread.start()
|
singleWorkerThread.start()
|
||||||
|
|
||||||
# Start the SQL thread
|
# Start the SQL thread
|
||||||
sqlLookup = sqlThread()
|
sqlLookup = sqlThread()
|
||||||
sqlLookup.daemon = False # DON'T close the main program even if there are threads left. The closeEvent should command this thread to exit gracefully.
|
sqlLookup.daemon = False # DON'T close the main program even if there are threads left. The closeEvent should command this thread to exit gracefully.
|
||||||
sqlLookup.start()
|
sqlLookup.start()
|
||||||
|
|
||||||
# Start the cleanerThread
|
# Start the cleanerThread
|
||||||
singleCleanerThread = singleCleaner()
|
singleCleanerThread = singleCleaner()
|
||||||
singleCleanerThread.daemon = True # close the main program even if there are threads left
|
singleCleanerThread.daemon = True # close the main program even if there are threads left
|
||||||
singleCleanerThread.start()
|
singleCleanerThread.start()
|
||||||
|
|
||||||
shared.reloadMyAddressHashes()
|
shared.reloadMyAddressHashes()
|
||||||
shared.reloadBroadcastSendersForWhichImWatching()
|
shared.reloadBroadcastSendersForWhichImWatching()
|
||||||
|
|
||||||
if shared.safeConfigGetBoolean('bitmessagesettings', 'apienabled'):
|
if shared.safeConfigGetBoolean('bitmessagesettings', 'apienabled'):
|
||||||
try:
|
try:
|
||||||
apiNotifyPath = shared.config.get(
|
apiNotifyPath = shared.config.get(
|
||||||
'bitmessagesettings', 'apinotifypath')
|
'bitmessagesettings', 'apinotifypath')
|
||||||
except:
|
except:
|
||||||
apiNotifyPath = ''
|
apiNotifyPath = ''
|
||||||
if apiNotifyPath != '':
|
if apiNotifyPath != '':
|
||||||
with shared.printLock:
|
with shared.printLock:
|
||||||
print 'Trying to call', apiNotifyPath
|
print 'Trying to call', apiNotifyPath
|
||||||
|
|
||||||
call([apiNotifyPath, "startingUp"])
|
call([apiNotifyPath, "startingUp"])
|
||||||
singleAPIThread = singleAPI()
|
singleAPIThread = singleAPI()
|
||||||
singleAPIThread.daemon = True # close the main program even if there are threads left
|
singleAPIThread.daemon = True # close the main program even if there are threads left
|
||||||
singleAPIThread.start()
|
singleAPIThread.start()
|
||||||
|
|
||||||
connectToStream(1)
|
connectToStream(1)
|
||||||
|
|
||||||
singleListenerThread = singleListener()
|
singleListenerThread = singleListener()
|
||||||
singleListenerThread.setup(selfInitiatedConnections)
|
singleListenerThread.setup(selfInitiatedConnections)
|
||||||
singleListenerThread.daemon = True # close the main program even if there are threads left
|
singleListenerThread.daemon = True # close the main program even if there are threads left
|
||||||
singleListenerThread.start()
|
singleListenerThread.start()
|
||||||
|
|
||||||
if not shared.safeConfigGetBoolean('bitmessagesettings', 'daemon'):
|
if deamon == False and shared.safeConfigGetBoolean('bitmessagesettings', 'daemon') == False:
|
||||||
try:
|
try:
|
||||||
from PyQt4 import QtCore, QtGui
|
from PyQt4 import QtCore, QtGui
|
||||||
except Exception as err:
|
except Exception as err:
|
||||||
print 'PyBitmessage requires PyQt unless you want to run it as a daemon and interact with it using the API. You can download PyQt from http://www.riverbankcomputing.com/software/pyqt/download or by searching Google for \'PyQt Download\'. If you want to run in daemon mode, see https://bitmessage.org/wiki/Daemon'
|
print 'PyBitmessage requires PyQt unless you want to run it as a daemon and interact with it using the API. You can download PyQt from http://www.riverbankcomputing.com/software/pyqt/download or by searching Google for \'PyQt Download\'. If you want to run in daemon mode, see https://bitmessage.org/wiki/Daemon'
|
||||||
print 'Error message:', err
|
print 'Error message:', err
|
||||||
os._exit(0)
|
os._exit(0)
|
||||||
|
|
||||||
import bitmessageqt
|
import bitmessageqt
|
||||||
bitmessageqt.run()
|
bitmessageqt.run()
|
||||||
else:
|
else:
|
||||||
shared.config.remove_option('bitmessagesettings', 'dontconnect')
|
shared.config.remove_option('bitmessagesettings', 'dontconnect')
|
||||||
|
|
||||||
|
if deamon:
|
||||||
|
with shared.printLock:
|
||||||
|
print 'Running as a daemon. The main program should exit this thread.'
|
||||||
|
else:
|
||||||
|
with shared.printLock:
|
||||||
|
print 'Running as a daemon. You can use Ctrl+C to exit.'
|
||||||
|
while True:
|
||||||
|
time.sleep(20)
|
||||||
|
|
||||||
|
def stop(self):
|
||||||
with shared.printLock:
|
with shared.printLock:
|
||||||
print 'Running as a daemon. You can use Ctrl+C to exit.'
|
print 'Stopping Bitmessage Deamon.'
|
||||||
|
shared.doCleanShutdown()
|
||||||
while True:
|
|
||||||
time.sleep(20)
|
|
||||||
|
def getApiAddress(self):
|
||||||
|
if not shared.safeConfigGetBoolean('bitmessagesettings', 'apienabled'):
|
||||||
|
return None
|
||||||
|
|
||||||
|
address = shared.config.get('bitmessagesettings', 'apiinterface')
|
||||||
|
port = shared.config.getint('bitmessagesettings', 'apiport')
|
||||||
|
return {'address':address,'port':port}
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
mainprogram = Main()
|
||||||
|
mainprogram.start()
|
||||||
|
|
||||||
|
|
||||||
# So far, the creation of and management of the Bitmessage protocol and this
|
# So far, the creation of and management of the Bitmessage protocol and this
|
||||||
# client is a one-man operation. Bitcoin tips are quite appreciated.
|
# client is a one-man operation. Bitcoin tips are quite appreciated.
|
||||||
# 1H5XaDA6fYENLbknwZyjiYXYPQaFjjLX2u
|
# 1H5XaDA6fYENLbknwZyjiYXYPQaFjjLX2u
|
||||||
|
|
Reference in New Issue
Block a user