Skip to content
This repository has been archived by the owner on Jan 19, 2024. It is now read-only.

Config restart fix #67

Merged
merged 4 commits into from
Nov 22, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .pylintrc
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
28 changes: 11 additions & 17 deletions src/dune/dune.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.")
Expand All @@ -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 nod.config() is not None:
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()])
Expand Down