Added cmd flag --init to start command
This commit is contained in:
parent
037dd65186
commit
5954d6360a
|
@ -196,7 +196,9 @@ def run_start(args):
|
||||||
logger.info('RethinkDB started with PID %s' % proc.pid)
|
logger.info('RethinkDB started with PID %s' % proc.pid)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
_run_init()
|
if args.initialize_database:
|
||||||
|
logger.info('Initializing database')
|
||||||
|
_run_init()
|
||||||
except DatabaseAlreadyExists:
|
except DatabaseAlreadyExists:
|
||||||
pass
|
pass
|
||||||
except KeypairNotFoundException:
|
except KeypairNotFoundException:
|
||||||
|
@ -300,6 +302,11 @@ def create_parser():
|
||||||
action='store_true',
|
action='store_true',
|
||||||
help='Run RethinkDB on start')
|
help='Run RethinkDB on start')
|
||||||
|
|
||||||
|
start_parser.add_argument('--init',
|
||||||
|
dest='initialize_database',
|
||||||
|
action='store_true',
|
||||||
|
help='Force initialize database')
|
||||||
|
|
||||||
# parser for configuring the number of shards
|
# parser for configuring the number of shards
|
||||||
sharding_parser = subparsers.add_parser('set-shards',
|
sharding_parser = subparsers.add_parser('set-shards',
|
||||||
help='Configure number of shards')
|
help='Configure number of shards')
|
||||||
|
|
|
@ -25,7 +25,7 @@ services:
|
||||||
BIGCHAINDB_GRAPHITE_HOST: graphite
|
BIGCHAINDB_GRAPHITE_HOST: graphite
|
||||||
ports:
|
ports:
|
||||||
- "9984"
|
- "9984"
|
||||||
command: bigchaindb start
|
command: bigchaindb start --init
|
||||||
|
|
||||||
graphite:
|
graphite:
|
||||||
image: hopsoft/graphite-statsd
|
image: hopsoft/graphite-statsd
|
||||||
|
|
|
@ -45,4 +45,4 @@ services:
|
||||||
BIGCHAINDB_SERVER_BIND: 0.0.0.0:9984
|
BIGCHAINDB_SERVER_BIND: 0.0.0.0:9984
|
||||||
ports:
|
ports:
|
||||||
- "9984"
|
- "9984"
|
||||||
command: bigchaindb start
|
command: bigchaindb start --init
|
||||||
|
|
|
@ -30,4 +30,4 @@ services:
|
||||||
BIGCHAINDB_WSSERVER_HOST: 0.0.0.0
|
BIGCHAINDB_WSSERVER_HOST: 0.0.0.0
|
||||||
ports:
|
ports:
|
||||||
- "9984"
|
- "9984"
|
||||||
command: bigchaindb start
|
command: bigchaindb start --init
|
||||||
|
|
|
@ -49,6 +49,7 @@ def run_start_args(request):
|
||||||
config=param.get('config'),
|
config=param.get('config'),
|
||||||
start_rethinkdb=param.get('start_rethinkdb', False),
|
start_rethinkdb=param.get('start_rethinkdb', False),
|
||||||
allow_temp_keypair=param.get('allow_temp_keypair', False),
|
allow_temp_keypair=param.get('allow_temp_keypair', False),
|
||||||
|
initialize_database=param.get('initialize_database', True),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -39,7 +39,8 @@ def test_bigchain_run_start(mock_run_configure,
|
||||||
mocked_setup_logging):
|
mocked_setup_logging):
|
||||||
from bigchaindb import config
|
from bigchaindb import config
|
||||||
from bigchaindb.commands.bigchaindb import run_start
|
from bigchaindb.commands.bigchaindb import run_start
|
||||||
args = Namespace(start_rethinkdb=False, allow_temp_keypair=False, config=None, yes=True)
|
args = Namespace(start_rethinkdb=False, allow_temp_keypair=False, config=None, yes=True,
|
||||||
|
initialize_database=True)
|
||||||
run_start(args)
|
run_start(args)
|
||||||
mocked_setup_logging.assert_called_once_with(user_log_config=config['log'])
|
mocked_setup_logging.assert_called_once_with(user_log_config=config['log'])
|
||||||
|
|
||||||
|
@ -288,7 +289,8 @@ def test_allow_temp_keypair_generates_one_on_the_fly(
|
||||||
|
|
||||||
bigchaindb.config['keypair'] = {'private': None, 'public': None}
|
bigchaindb.config['keypair'] = {'private': None, 'public': None}
|
||||||
|
|
||||||
args = Namespace(allow_temp_keypair=True, start_rethinkdb=False, config=None, yes=True)
|
args = Namespace(allow_temp_keypair=True, start_rethinkdb=False, config=None, yes=True,
|
||||||
|
initialize_database=True)
|
||||||
run_start(args)
|
run_start(args)
|
||||||
|
|
||||||
mocked_setup_logging.assert_called_once_with(
|
mocked_setup_logging.assert_called_once_with(
|
||||||
|
@ -314,7 +316,8 @@ def test_allow_temp_keypair_doesnt_override_if_keypair_found(mock_gen_keypair,
|
||||||
assert isinstance(original_public_key, str)
|
assert isinstance(original_public_key, str)
|
||||||
assert isinstance(original_private_key, str)
|
assert isinstance(original_private_key, str)
|
||||||
|
|
||||||
args = Namespace(allow_temp_keypair=True, start_rethinkdb=False, config=None, yes=True)
|
args = Namespace(allow_temp_keypair=True, start_rethinkdb=False, config=None, yes=True,
|
||||||
|
initialize_database=True)
|
||||||
run_start(args)
|
run_start(args)
|
||||||
|
|
||||||
mocked_setup_logging.assert_called_once_with(
|
mocked_setup_logging.assert_called_once_with(
|
||||||
|
|
Loading…
Reference in New Issue