Remove exception stacktrace when starting without keypair

This commit is contained in:
vrde 2016-04-08 15:56:10 +02:00
parent c92d285fa8
commit 8215576497
No known key found for this signature in database
GPG Key ID: 6581C7C39B3D397D
3 changed files with 9 additions and 21 deletions

View File

@ -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()

View File

@ -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!')

View File

@ -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 <module>
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.