Add shutdown command to API

- calling "shutdown" now cleanly shuts down PyBitmessage, however the
call may not return so you need to add an error handler to the call.
With python for example, wrap the "shutdown()" in
"try:/except socket.error"
This commit is contained in:
Peter Šurda 2017-08-21 10:39:03 +02:00
parent b886f935d4
commit b7f808cde1
Signed by untrusted user: PeterSurda
GPG Key ID: 0C5F50C0B5F37D87
1 changed files with 6 additions and 0 deletions

View File

@ -30,6 +30,7 @@ import protocol
import state import state
from pyelliptic.openssl import OpenSSL from pyelliptic.openssl import OpenSSL
import queues import queues
import shutdown
from struct import pack from struct import pack
import network.stats import network.stats
@ -982,6 +983,10 @@ class MySimpleXMLRPCRequestHandler(SimpleXMLRPCRequestHandler):
sqlStoredProcedure('deleteandvacuume') sqlStoredProcedure('deleteandvacuume')
return 'done' return 'done'
def HandleShutdown(self, params):
shutdown.doCleanShutdown()
return 'done'
handlers = {} handlers = {}
handlers['helloWorld'] = HandleHelloWorld handlers['helloWorld'] = HandleHelloWorld
handlers['add'] = HandleAdd handlers['add'] = HandleAdd
@ -1032,6 +1037,7 @@ class MySimpleXMLRPCRequestHandler(SimpleXMLRPCRequestHandler):
handlers['clientStatus'] = HandleClientStatus handlers['clientStatus'] = HandleClientStatus
handlers['decodeAddress'] = HandleDecodeAddress handlers['decodeAddress'] = HandleDecodeAddress
handlers['deleteAndVacuum'] = HandleDeleteAndVacuum handlers['deleteAndVacuum'] = HandleDeleteAndVacuum
handlers['shutdown'] = HandleShutdown
def _handle_request(self, method, params): def _handle_request(self, method, params):
if (self.handlers.has_key(method)): if (self.handlers.has_key(method)):