Changed start code for deamon mode #377

Merged
merlink01 merged 3 commits from master into master 2013-08-07 21:21:02 +02:00

View File

@ -770,7 +770,8 @@ if shared.useVeryEasyProofOfWorkForTesting:
shared.networkDefaultPayloadLengthExtraBytes = int( shared.networkDefaultPayloadLengthExtraBytes = int(
shared.networkDefaultPayloadLengthExtraBytes / 7000) shared.networkDefaultPayloadLengthExtraBytes / 7000)
if __name__ == "__main__": class Main:
def start(self, deamon=False):
# is the application already running? If yes then exit. # is the application already running? If yes then exit.
thisapp = singleton.singleinstance() thisapp = singleton.singleinstance()
@ -823,7 +824,7 @@ if __name__ == "__main__":
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:
@ -835,12 +836,35 @@ if __name__ == "__main__":
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: with shared.printLock:
print 'Running as a daemon. You can use Ctrl+C to exit.' print 'Running as a daemon. You can use Ctrl+C to exit.'
while True: while True:
time.sleep(20) time.sleep(20)
def stop(self):
with shared.printLock:
print 'Stopping Bitmessage Deamon.'
shared.doCleanShutdown()
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