@@ -27,15 +27,16 @@ def __init__(self):
2727 def process_containers (self ):
2828 containers = self .docker_client .containers .list (all = True , filters = { "label" : ["swag_ondemand=enable" ] })
2929 container_names = {container .name for container in containers }
30-
30+
3131 for container_name in list (self .ondemand_containers .keys ()):
3232 if container_name in container_names :
3333 continue
3434 self .ondemand_containers .pop (container_name )
3535 logging .info (f"Stopped monitoring { container_name } " )
36-
36+
3737 for container in containers :
38- container_urls = container .labels .get ("swag_ondemand_urls" , f"https://{ container .name } .,http://{ container .name } ." )
38+ default_url = container .labels .get ("swag_url" , f"{ container .name } ." ).rstrip ("*" )
39+ container_urls = container .labels .get ("swag_ondemand_urls" , f"https://{ default_url } ,http://{ default_url } " )
3940 if container .name not in self .ondemand_containers .keys ():
4041 last_accessed = datetime .now ()
4142 logging .info (f"Started monitoring { container .name } " )
@@ -52,12 +53,12 @@ def stop_containers(self):
5253 continue
5354 self .docker_client .containers .get (container_name ).stop ()
5455 logging .info (f"Stopped { container_name } after { STOP_THRESHOLD } s of inactivity" )
55-
56+
5657 def start_containers (self ):
5758 with last_accessed_urls_lock :
5859 last_accessed_urls_combined = "," .join (last_accessed_urls )
5960 last_accessed_urls .clear ()
60-
61+
6162 for container_name in self .ondemand_containers .keys ():
6263 accessed = False
6364 for ondemand_url in self .ondemand_containers [container_name ]["urls" ].split ("," ):
@@ -85,7 +86,7 @@ class LogReaderThread(threading.Thread):
8586 def __init__ (self ):
8687 super ().__init__ ()
8788 self .daemon = True
88-
89+
8990 def tail (self , f ):
9091 f .seek (0 ,2 )
9192 inode = os .fstat (f .fileno ()).st_ino
@@ -131,6 +132,6 @@ def run(self):
131132
132133 ContainerThread ().start ()
133134 LogReaderThread ().start ()
134-
135+
135136 while True :
136137 time .sleep (1 )
0 commit comments