Skip to content

Commit

Permalink
SKALE-2738 Add sync schains option to the update procedure
Browse files Browse the repository at this point in the history
  • Loading branch information
dmytrotkk committed Jul 29, 2020
1 parent 60363ce commit 96db511
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 5 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,7 @@ skale node update

Options:

- `--sync-schains` - run sChains in the backup recovery mode after restart
- `--yes` - remove without additional confirmation

You can also specify a file with environment variables
Expand Down
5 changes: 3 additions & 2 deletions cli/node.py
Original file line number Diff line number Diff line change
Expand Up @@ -153,12 +153,13 @@ def init_node(env_file, install_deps, dry_run):


@node.command('update', help='De-register node from the SKALE Manager')
@click.option('--sync-schains', is_flag=True)
@click.option('--yes', is_flag=True, callback=abort_if_false,
expose_value=False,
prompt='Are you sure you want to update SKALE node software?')
@click.argument('env_file')
def update_node(env_file):
update(env_file)
def update_node(sync_schains, env_file):
update(env_file, sync_schains)
print('Waiting for transaction manager initialization ...')
time.sleep(20)

Expand Down
10 changes: 7 additions & 3 deletions core/node.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ def deregister():
pass


def update(env_filepath):
def update(env_filepath, sync_schains):
if env_filepath is not None:
env_params = extract_env_params(env_filepath)
if env_params is None:
Expand All @@ -133,12 +133,16 @@ def update(env_filepath):
env_params['SGX_SERVER_URL']
)
flask_secret_key = get_flask_secret_key()
res_update_node = subprocess.run(['bash', UPDATE_SCRIPT], env={
update_cmd_env = {
'SKALE_DIR': SKALE_DIR,
'FLASK_SECRET_KEY': flask_secret_key,
'DATAFILES_FOLDER': DATAFILES_FOLDER,
**env_params
})
}
if sync_schains:
update_cmd_env['BACKUP_RUN'] = 'True'

res_update_node = subprocess.run(['bash', UPDATE_SCRIPT], env=update_cmd_env)
logger.info(
f'Update node script result: '
f'{res_update_node.stderr}, {res_update_node.stdout}')
Expand Down

0 comments on commit 96db511

Please sign in to comment.