Created Object for controlling bitmessage deamon

This commit is contained in:
merlink 2013-08-06 13:23:56 +02:00 committed by Jordan Hall
parent 28acbac823
commit 7850e9aa68
1 changed files with 80 additions and 59 deletions

View File

@ -770,7 +770,8 @@ if shared.useVeryEasyProofOfWorkForTesting:
shared.networkDefaultPayloadLengthExtraBytes = int(
shared.networkDefaultPayloadLengthExtraBytes / 7000)
def main(deamon=False):
class Main:
def start(self, deamon=False):
# is the application already running? If yes then exit.
thisapp = singleton.singleinstance()
@ -835,14 +836,34 @@ def main(deamon=False):
bitmessageqt.run()
else:
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:
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__":
main()
mainprogram = Main()
mainprogram.start()
# So far, the creation of and management of the Bitmessage protocol and this
# client is a one-man operation. Bitcoin tips are quite appreciated.