Skip to content

Commit

Permalink
chore(xudctl): refine connext status (#513)
Browse files Browse the repository at this point in the history
* chore(xudctl): refine connext status

This PR keeps align with xud getinfo connext status.

Closes #512.

* fix api missing in Dict

* add another status text
  • Loading branch information
reliveyy authored Jun 18, 2020
1 parent a99814f commit 2a60535
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 1 deletion.
3 changes: 2 additions & 1 deletion images/utils/launcher/node/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ class Context:
shell: Shell
client: docker.DockerClient
image_manager: ImageManager
node_manager: 'NodeManager'


class NodeNotFound(Exception):
Expand All @@ -112,7 +113,7 @@ def __init__(self, config, shell):
self.branch = self.config.branch
self.network = self.config.network

ctx = Context(self.config, self.shell, self.client, self.image_manager)
ctx = Context(self.config, self.shell, self.client, self.image_manager, self)

self.nodes = {name: globals()[name.capitalize()](name, ctx) for name in self.config.nodes}
self.docker_network = self.create_docker_network()
Expand Down
1 change: 1 addition & 0 deletions images/utils/launcher/node/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ def __init__(self, name: str, ctx):
self.client = docker.from_env(timeout=999999999)
self.config = ctx.config
self.image_manager = ctx.image_manager
self.node_manager = ctx.node_manager

self.name = name

Expand Down
15 changes: 15 additions & 0 deletions images/utils/launcher/node/connext.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,12 +71,27 @@ def __init__(self, name, ctx):
self._cli = "curl -s"
self.api = ConnextApi(CliBackend(self.client, self.container_name, self._logger, self._cli))

def get_xud_getinfo_connext_status(self):
xud = self.node_manager.nodes["xud"]
info = xud.api.getinfo()
status = info["connext"]["status"]
if status == "Ready":
return "Ready"
elif "ECONNREFUSED" in status:
return "Can't connect to Connext node"
else:
return "Starting..."

def status(self):
status = super().status()
if status == "exited":
# TODO: analyze exit reason
return "Container exited"
elif status == "running":
try:
return self.get_xud_getinfo_connext_status()
except:
self._logger.exception("Failed to get connext status from xud getinfo")
try:
healthy = self.api.is_healthy()
if healthy:
Expand Down

0 comments on commit 2a60535

Please sign in to comment.