parent
616d170e9a
commit
7944e0cd98
|
@ -19,7 +19,7 @@ ENV BIGCHAINDB_CONFIG_PATH /data/.bigchaindb
|
|||
ENV BIGCHAINDB_SERVER_BIND 0.0.0.0:9984
|
||||
ENV BIGCHAINDB_API_ENDPOINT http://bigchaindb:9984/api/v1
|
||||
|
||||
ENTRYPOINT ["bigchaindb", "--experimental-start-rethinkdb"]
|
||||
ENTRYPOINT ["bigchaindb", "--dev-start-rethinkdb", "--dev-allow-temp-keypair"]
|
||||
|
||||
CMD ["start"]
|
||||
|
||||
|
|
|
@ -157,8 +157,20 @@ def run_drop(args):
|
|||
def run_start(args):
|
||||
"""Start the processes to run the node"""
|
||||
logger.info('BigchainDB Version {}'.format(bigchaindb.__version__))
|
||||
|
||||
bigchaindb.config_utils.autoconfigure(filename=args.config, force=True)
|
||||
|
||||
if args.allow_temp_keypair:
|
||||
if not (bigchaindb.config['keypair']['private'] or
|
||||
bigchaindb.config['keypair']['public']):
|
||||
|
||||
private_key, public_key = crypto.generate_key_pair()
|
||||
bigchaindb.config['keypair']['private'] = private_key
|
||||
bigchaindb.config['keypair']['public'] = public_key
|
||||
else:
|
||||
logger.warning('Keypair found, no need to create one on the fly.')
|
||||
|
||||
|
||||
if args.start_rethinkdb:
|
||||
try:
|
||||
proc = utils.start_rethinkdb()
|
||||
|
@ -174,7 +186,8 @@ def run_start(args):
|
|||
sys.exit("Can't start BigchainDB, no keypair found. "
|
||||
'Did you run `bigchaindb configure`?')
|
||||
|
||||
logger.info('Starting BigchainDB main process')
|
||||
logger.info('Starting BigchainDB main process with public key %s',
|
||||
bigchaindb.config['keypair']['public'])
|
||||
processes.start()
|
||||
|
||||
|
||||
|
@ -238,11 +251,16 @@ def main():
|
|||
description='Control your BigchainDB node.',
|
||||
parents=[utils.base_parser])
|
||||
|
||||
parser.add_argument('--experimental-start-rethinkdb',
|
||||
parser.add_argument('--dev-start-rethinkdb',
|
||||
dest='start_rethinkdb',
|
||||
action='store_true',
|
||||
help='Run RethinkDB on start')
|
||||
|
||||
parser.add_argument('--dev-allow-temp-keypair',
|
||||
dest='allow_temp_keypair',
|
||||
action='store_true',
|
||||
help='Generate a random keypair on start')
|
||||
|
||||
# all the commands are contained in the subparsers object,
|
||||
# the command selected by the user will be stored in `args.command`
|
||||
# that is used by the `main` function to select which other
|
||||
|
|
|
@ -58,8 +58,9 @@ Drop (erase) the RethinkDB database. You will be prompted to make sure. If you w
|
|||
## bigchaindb start
|
||||
|
||||
Start BigchainDB. It always begins by trying a `bigchaindb init` first. See the note in the documentation for `bigchaindb init`.
|
||||
You can also use the `--experimental-start-rethinkdb` command line option to automatically start rethinkdb with bigchaindb if rethinkdb is not already running,
|
||||
e.g. `bigchaindb --experimental-start-rethinkdb start`. Note that this will also shutdown rethinkdb when the bigchaindb process stops.
|
||||
You can also use the `--dev-start-rethinkdb` command line option to automatically start rethinkdb with bigchaindb if rethinkdb is not already running,
|
||||
e.g. `bigchaindb --dev-start-rethinkdb start`. Note that this will also shutdown rethinkdb when the bigchaindb process stops.
|
||||
The option `--dev-allow-temp-keypair` will generate a keypair on the fly if no keypair is found, this is useful when you want to run a temporary instance of BigchainDB in a Docker container, for example.
|
||||
|
||||
|
||||
## bigchaindb load
|
||||
|
|
|
@ -64,7 +64,7 @@ def mock_bigchaindb_backup_config(monkeypatch):
|
|||
|
||||
def test_bigchain_run_start(mock_run_configure, mock_processes_start, mock_db_init_with_existing_db):
|
||||
from bigchaindb.commands.bigchain import run_start
|
||||
args = Namespace(start_rethinkdb=False, config=None, yes=True)
|
||||
args = Namespace(start_rethinkdb=False, allow_temp_keypair=False, config=None, yes=True)
|
||||
run_start(args)
|
||||
|
||||
|
||||
|
@ -74,7 +74,7 @@ def test_bigchain_run_start_with_rethinkdb(mock_start_rethinkdb,
|
|||
mock_processes_start,
|
||||
mock_db_init_with_existing_db):
|
||||
from bigchaindb.commands.bigchain import run_start
|
||||
args = Namespace(start_rethinkdb=True, config=None, yes=True)
|
||||
args = Namespace(start_rethinkdb=True, allow_temp_keypair=False, config=None, yes=True)
|
||||
run_start(args)
|
||||
|
||||
mock_start_rethinkdb.assert_called_with()
|
||||
|
@ -229,6 +229,42 @@ def test_start_rethinkdb_exits_when_cannot_start(mock_popen):
|
|||
utils.start_rethinkdb()
|
||||
|
||||
|
||||
@patch('bigchaindb.crypto.generate_key_pair', return_value=('private_key',
|
||||
'public_key'))
|
||||
def test_allow_temp_keypair_generates_one_on_the_fly(mock_gen_keypair,
|
||||
mock_processes_start,
|
||||
mock_db_init_with_existing_db):
|
||||
import bigchaindb
|
||||
from bigchaindb.commands.bigchain import run_start
|
||||
|
||||
bigchaindb.config['keypair'] = { 'private': None, 'public': None }
|
||||
|
||||
args = Namespace(allow_temp_keypair=True, start_rethinkdb=False, config=None, yes=True)
|
||||
run_start(args)
|
||||
|
||||
assert bigchaindb.config['keypair']['private'] == 'private_key'
|
||||
assert bigchaindb.config['keypair']['public'] == 'public_key'
|
||||
|
||||
|
||||
@patch('bigchaindb.crypto.generate_key_pair', return_value=('private_key',
|
||||
'public_key'))
|
||||
def test_allow_temp_keypair_doesnt_override_if_keypair_found(mock_gen_keypair,
|
||||
mock_processes_start,
|
||||
mock_db_init_with_existing_db):
|
||||
import bigchaindb
|
||||
from bigchaindb.commands.bigchain import run_start
|
||||
|
||||
# Preconditions for the test
|
||||
assert isinstance(bigchaindb.config['keypair']['private'], str)
|
||||
assert isinstance(bigchaindb.config['keypair']['public'], str)
|
||||
|
||||
args = Namespace(allow_temp_keypair=True, start_rethinkdb=False, config=None, yes=True)
|
||||
run_start(args)
|
||||
|
||||
assert bigchaindb.config['keypair']['private'] != 'private_key'
|
||||
assert bigchaindb.config['keypair']['public'] != 'public_key'
|
||||
|
||||
|
||||
@patch('rethinkdb.ast.Table.reconfigure')
|
||||
def test_set_shards(mock_reconfigure, monkeypatch, b):
|
||||
from bigchaindb.commands.bigchain import run_set_shards
|
||||
|
|
Loading…
Reference in New Issue