21
21
from .lnd import Lndbtc , Lndltc
22
22
from .webui import Webui
23
23
from .xud import Xud , XudApiError
24
+ from .DockerTemplate import DockerTemplate
24
25
from ..config import Config
25
26
from ..errors import FatalError
26
27
from ..shell import Shell
@@ -125,6 +126,8 @@ def __init__(self, config, shell):
125
126
self .cmd_stop = StopCommand (self .get_node , self .shell )
126
127
self .cmd_restart = RestartCommand (self .get_node , self .shell )
127
128
129
+ self .docker_template = DockerTemplate ()
130
+
128
131
@property
129
132
def network_name (self ):
130
133
return self .network + "_default"
@@ -176,7 +179,7 @@ def up(self):
176
179
nodes = self .valid_nodes .values ()
177
180
178
181
def print_failed (failed ):
179
- print ("Failed to start these nodes. " )
182
+ print ("Failed to start these services: " )
180
183
for f in failed :
181
184
print (f"- { f [0 ].name } : { str (f [1 ])} " )
182
185
@@ -219,11 +222,12 @@ def _readable_details(self, details):
219
222
diff_keys = [key for key , value in details .items () if not value .same ]
220
223
return ", " .join (diff_keys )
221
224
222
- def update (self ):
225
+ def update (self ) -> bool :
223
226
if self .config .disable_update :
224
- return
227
+ return True
225
228
226
229
outdated = False
230
+ image_outdated = False
227
231
228
232
# Step 1. check all images
229
233
print ("🌍 Checking for updates..." )
@@ -237,6 +241,7 @@ def update(self):
237
241
if status in ["LOCAL_MISSING" , "LOCAL_OUTDATED" ]:
238
242
print ("- Image %s: %s" % (image .name , image .status_message ))
239
243
outdated = True
244
+ image_outdated = True
240
245
elif status == "UNAVAILABLE" :
241
246
all_unavailable_images = [x for x in images if x .status == "UNAVAILABLE" ]
242
247
raise FatalError ("Image(s) not available: %r" % all_unavailable_images )
@@ -277,12 +282,18 @@ def handle_result(container, result):
277
282
278
283
if not outdated :
279
284
print ("All up-to-date." )
280
- return
285
+ return True
281
286
282
287
all_containers_missing = functools .reduce (lambda a , b : a and b [0 ] in ["missing" , "external" , "disabled" ], container_check_result .values (), True )
283
288
284
289
if all_containers_missing :
285
- answer = "yes"
290
+ if self .newly_installed :
291
+ answer = "yes"
292
+ else :
293
+ if image_outdated :
294
+ answer = "yes"
295
+ else :
296
+ return True # FIXME unintended containers (configuration) update
286
297
else :
287
298
answer = self .shell .yes_or_no ("A new version is available. Would you like to upgrade (Warning: this may restart your environment and cancel all open orders)?" )
288
299
@@ -297,6 +308,9 @@ def handle_result(container, result):
297
308
# 2.2) recreate outdated containers
298
309
for container , result in container_check_result .items ():
299
310
container .update (result )
311
+ return True
312
+ else :
313
+ return False
300
314
301
315
def logs (self , * args ):
302
316
self .cmd_logs .execute (args )
@@ -313,9 +327,21 @@ def restart(self, *args):
313
327
def cli (self , name , * args ):
314
328
self .get_node (name ).cli (" " .join (args ), self .shell )
315
329
330
+ def _get_status_nodes (self ):
331
+ optional_nodes = ["arby" , "boltz" , "webui" ]
332
+ result = {}
333
+ for node in self .nodes .values ():
334
+ if node .name in optional_nodes :
335
+ c = self .docker_template .get_container (node .container_name )
336
+ if c :
337
+ result [node .name ] = node
338
+ else :
339
+ result [node .name ] = node
340
+ return result
341
+
316
342
def status (self ):
317
343
# TODO migrate to ServiceTable
318
- nodes = self .enabled_nodes
344
+ nodes = self ._get_status_nodes ()
319
345
names = list (nodes )
320
346
321
347
BRIGHT_BLACK = "\033 [90m"
0 commit comments