From 0c33b4c2111c33b458a9e2731cbbbe016f1ac570 Mon Sep 17 00:00:00 2001 From: Muawia Khan Date: Thu, 26 Jul 2018 14:42:32 +0200 Subject: [PATCH] Problem: Signals do not propagate to child BigchainDB processes (#2395). Solution: Run child processes as daemons to make the signals propagate. Add a short shutdown description to the setup guide. --- bigchaindb/start.py | 10 +++--- docs/server/source/simple-network-setup.md | 42 ++++++++++++++++++++++ 2 files changed, 48 insertions(+), 4 deletions(-) diff --git a/bigchaindb/start.py b/bigchaindb/start.py index 4bcc8218..e606ac11 100644 --- a/bigchaindb/start.py +++ b/bigchaindb/start.py @@ -1,5 +1,4 @@ import logging - import setproctitle import bigchaindb @@ -34,14 +33,14 @@ BANNER = """ def start(): # Exchange object for event stream api + logger.info('Starting BigchainDB') exchange = Exchange() - # start the web api app_server = server.create_server( settings=bigchaindb.config['server'], log_config=bigchaindb.config['log'], bigchaindb_factory=BigchainDB) - p_webapi = Process(name='bigchaindb_webapi', target=app_server.run) + p_webapi = Process(name='bigchaindb_webapi', target=app_server.run, daemon=True) p_webapi.start() # start message @@ -50,16 +49,18 @@ def start(): # start websocket server p_websocket_server = Process(name='bigchaindb_ws', target=websocket_server.start, + daemon=True, args=(exchange.get_subscriber_queue(EventTypes.BLOCK_VALID),)) p_websocket_server.start() # connect to tendermint event stream p_websocket_client = Process(name='bigchaindb_ws_to_tendermint', target=event_stream.start, + daemon=True, args=(exchange.get_publisher_queue(),)) p_websocket_client.start() - p_exchange = Process(name='bigchaindb_exchange', target=exchange.run) + p_exchange = Process(name='bigchaindb_exchange', target=exchange.run, daemon=True) p_exchange.start() # We need to import this after spawning the web server @@ -69,6 +70,7 @@ def start(): setproctitle.setproctitle('bigchaindb') + # Start the ABCIServer app = ABCIServer(app=App()) app.run() diff --git a/docs/server/source/simple-network-setup.md b/docs/server/source/simple-network-setup.md index dc13dd43..a52bde17 100644 --- a/docs/server/source/simple-network-setup.md +++ b/docs/server/source/simple-network-setup.md @@ -265,6 +265,48 @@ If you want to refresh your node back to a fresh empty state, then your best bet - reset Tendermint using `tendermint unsafe_reset_all` - delete the directory `$HOME/.tendermint` +## Shutting down BigchainDB + +If you want to stop/kill BigchainDB, you can do so by sending `SIGINT`, `SIGQUIT` or `SIGTERM` to the running BigchainDB +process(es). Depending on how you started BigchainDB i.e. foreground or background. e.g. you started BigchainDB in the background as mentioned above in the guide: + +```bash +$ nohup bigchaindb start 2>&1 > bigchaindb.log & + +$ # Check the PID of the main BigchainDB process +$ ps -ef | grep bigchaindb + *