From c957798c451e203cebbe835f74c5c3b57c1f9eea Mon Sep 17 00:00:00 2001 From: Scott Bailey Date: Mon, 21 Nov 2022 13:43:57 -0600 Subject: [PATCH 1/4] Correct restart to use existing config. --- src/dune/dune.py | 28 +++++++++++----------------- 1 file changed, 11 insertions(+), 17 deletions(-) diff --git a/src/dune/dune.py b/src/dune/dune.py index 9dcb259f..de127a12 100644 --- a/src/dune/dune.py +++ b/src/dune/dune.py @@ -101,8 +101,7 @@ def create_node(self, nod): self._docker.execute_cmd(['mkdir', '-p', nod.data_dir()]) def start_node(self, nod, snapshot=None): - stdout, stderr, exit_code = self._docker.execute_cmd( - ['ls', '/app/nodes']) + stdout, stderr, exit_code = self._docker.execute_cmd(['ls', '/app/nodes']) if self.is_node_running(nod): print("Node [" + nod.name() + "] is already running.") @@ -111,41 +110,36 @@ def start_node(self, nod, snapshot=None): cmd = ['sh', 'start_node.sh', nod.data_dir(), nod.config_dir()] if snapshot is not None: - cmd = cmd + [ - '--snapshot /app/nodes/' + nod.name() + '/snapshots/' + - snapshot + ' -e'] + cmd = cmd + ['--snapshot /app/nodes/' + nod.name() + '/snapshots/' + snapshot + ' -e'] else: cmd = cmd + [' '] # if node name is not found we need to create it + is_restart=True if not nod.name() in stdout: + is_restart=False self.create_node(nod) # copy config.ini to config-dir - if nod.config() is None: + if not is_restart and nod.config() is None: nod.set_config('/app/config.ini') - self._docker.execute_cmd(['cp', nod.config(), nod.config_dir()]) - print("Using Configuration [" + nod.config() + "]") + if not is_restart: + self._docker.execute_cmd(['cp', nod.config(), nod.config_dir()]) + print("Using Configuration [" + nod.config() + "]") ctx = self._context.get_ctx() cfg_args = self._context.get_config_args(nod) if self.node_exists(node(ctx.active)): if cfg_args[0] == ctx.http_port: - print( - "Currently active node [" + ctx.active + - "] http port is the same as this nodes [" + nod.name() + "]") + print("Currently active node [" + ctx.active + "] http port is the same as this nodes [" + nod.name() + "]") self.stop_node(node(ctx.active)) elif cfg_args[1] == ctx.p2p_port: - print( - "Currently active node [" + ctx.active + - "] p2p port is the same as this nodes [" + nod.name() + "]") + print("Currently active node [" + ctx.active + "] p2p port is the same as this nodes [" + nod.name() + "]") self.stop_node(node(ctx.active)) elif cfg_args[2] == ctx.ship_port: - print( - "Currently active node [" + ctx.active + - "] ship port is the same as this nodes [" + nod.name() + "]") + print("Currently active node [" + ctx.active + "] ship port is the same as this nodes [" + nod.name() + "]") self.stop_node(node(ctx.active)) stdout, stderr, exit_code = self._docker.execute_cmd(cmd + [nod.name()]) From e81cef45fe80421ca8c2d8b2413b9cb33a1fcdf1 Mon Sep 17 00:00:00 2001 From: Scott Bailey Date: Mon, 21 Nov 2022 13:46:51 -0600 Subject: [PATCH 2/4] Allow reasonable line length. --- .pylintrc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.pylintrc b/.pylintrc index 6c9ffe15..60e6a826 100644 --- a/.pylintrc +++ b/.pylintrc @@ -327,7 +327,8 @@ indent-after-paren=4 indent-string=' ' # Maximum number of characters on a single line. -max-line-length=100 +# 140 was chosen to work nicely on 14" laptops. +max-line-length=140 # Maximum number of lines in a module. max-module-lines=1000 From ac22fc72eeb4bc1751bd38f3ce63b992eb90e307 Mon Sep 17 00:00:00 2001 From: Scott Bailey Date: Mon, 21 Nov 2022 14:05:45 -0600 Subject: [PATCH 3/4] Allow for a restart with a new config. --- src/dune/dune.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/dune/dune.py b/src/dune/dune.py index de127a12..9a55effc 100644 --- a/src/dune/dune.py +++ b/src/dune/dune.py @@ -124,7 +124,7 @@ def start_node(self, nod, snapshot=None): if not is_restart and nod.config() is None: nod.set_config('/app/config.ini') - if not is_restart: + if nod.config() != None: self._docker.execute_cmd(['cp', nod.config(), nod.config_dir()]) print("Using Configuration [" + nod.config() + "]") From 5fe9c9c2fc0b79c84c289ef39e96119bbebd77b7 Mon Sep 17 00:00:00 2001 From: Scott Bailey Date: Mon, 21 Nov 2022 14:09:18 -0600 Subject: [PATCH 4/4] pylint correction. --- src/dune/dune.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/dune/dune.py b/src/dune/dune.py index 9a55effc..c12eb45f 100644 --- a/src/dune/dune.py +++ b/src/dune/dune.py @@ -124,7 +124,7 @@ def start_node(self, nod, snapshot=None): if not is_restart and nod.config() is None: nod.set_config('/app/config.ini') - if nod.config() != None: + if nod.config() is not None: self._docker.execute_cmd(['cp', nod.config(), nod.config_dir()]) print("Using Configuration [" + nod.config() + "]")