diff --git a/bigchaindb/commands/bigchain.py b/bigchaindb/commands/bigchain.py index c460ae15..912e5ed7 100644 --- a/bigchaindb/commands/bigchain.py +++ b/bigchaindb/commands/bigchain.py @@ -10,7 +10,7 @@ import json import bigchaindb import bigchaindb.config_utils from bigchaindb import db -from bigchaindb.exceptions import DatabaseAlreadyExists +from bigchaindb.exceptions import DatabaseAlreadyExists, KeypairNotFoundException from bigchaindb.commands.utils import base_parser, start from bigchaindb.processes import Processes from bigchaindb import crypto @@ -101,6 +101,10 @@ def run_start(args): db.init() except DatabaseAlreadyExists: pass + except KeypairNotFoundException: + print('Cannot start BigchainDB, no keypair found. Did you run `bigchaindb configure`?') + exit(1) + processes = Processes() logger.info('Start bigchaindb main process') processes.start() diff --git a/bigchaindb/db/utils.py b/bigchaindb/db/utils.py index d5551833..b0a44d6a 100644 --- a/bigchaindb/db/utils.py +++ b/bigchaindb/db/utils.py @@ -19,6 +19,9 @@ def get_conn(): def init(): + # Try to access the keypair, throws an exception if it does not exist + b = bigchaindb.Bigchain() + conn = get_conn() dbname = bigchaindb.config['database']['name'] @@ -59,7 +62,6 @@ def init(): r.db(dbname).table('bigchain').index_wait().run(conn) logger.info(' - genesis block') - b = bigchaindb.Bigchain() b.create_genesis_block() logger.info('Done, have fun!') diff --git a/docs/source/configuration.md b/docs/source/configuration.md index 6a906b96..efb71cc4 100644 --- a/docs/source/configuration.md +++ b/docs/source/configuration.md @@ -110,25 +110,7 @@ If we try to run the node, the command will fail: ``` $ bigchaindb start WARNING:bigchaindb.config_utils:Cannot find config file `/home/vrde/.bigchaindb`. -INFO:bigchaindb.db.utils:Create: -INFO:bigchaindb.db.utils: - database `bigchain` -INFO:bigchaindb.db.utils: - tables -INFO:bigchaindb.db.utils: - indexes -INFO:bigchaindb.db.utils: - genesis block -Traceback (most recent call last): - File "/home/vrde/.local/share/virtualenvs/bigchain/bin/bigchaindb", line 9, in - load_entry_point('BigchainDB', 'console_scripts', 'bigchaindb')() - File "/home/vrde/ascribe/repos/bigchaindb/bigchaindb/commands/bigchain.py", line 137, in main - start(parser, globals()) - File "/home/vrde/ascribe/repos/bigchaindb/bigchaindb/commands/utils.py", line 41, in start - func(args) - File "/home/vrde/ascribe/repos/bigchaindb/bigchaindb/commands/bigchain.py", line 101, in run_start - db.init() - File "/home/vrde/ascribe/repos/bigchaindb/bigchaindb/db/utils.py", line 62, in init - b = bigchaindb.Bigchain() - File "/home/vrde/ascribe/repos/bigchaindb/bigchaindb/core.py", line 58, in __init__ - raise exceptions.KeypairNotFoundException() -bigchaindb.exceptions.KeypairNotFoundException +Cannot start BigchainDB, no keypair found. Did you run `bigchaindb configure`? ``` This is failing as expected: a BigchainDB node needs at least a key pair to work.