From b7f808cde18c503502977cac679ea00682d4ab53 Mon Sep 17 00:00:00 2001 From: Peter Surda Date: Mon, 21 Aug 2017 10:39:03 +0200 Subject: [PATCH] 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" --- src/api.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/api.py b/src/api.py index dcc83538..05b27432 100644 --- a/src/api.py +++ b/src/api.py @@ -30,6 +30,7 @@ import protocol import state from pyelliptic.openssl import OpenSSL import queues +import shutdown from struct import pack import network.stats @@ -982,6 +983,10 @@ class MySimpleXMLRPCRequestHandler(SimpleXMLRPCRequestHandler): sqlStoredProcedure('deleteandvacuume') return 'done' + def HandleShutdown(self, params): + shutdown.doCleanShutdown() + return 'done' + handlers = {} handlers['helloWorld'] = HandleHelloWorld handlers['add'] = HandleAdd @@ -1032,6 +1037,7 @@ class MySimpleXMLRPCRequestHandler(SimpleXMLRPCRequestHandler): handlers['clientStatus'] = HandleClientStatus handlers['decodeAddress'] = HandleDecodeAddress handlers['deleteAndVacuum'] = HandleDeleteAndVacuum + handlers['shutdown'] = HandleShutdown def _handle_request(self, method, params): if (self.handlers.has_key(method)):