3
3
from time import sleep
4
4
import logging
5
5
import subprocess
6
- from typing import Optional , List
6
+ from typing import Optional , List , Dict , Set
7
7
8
8
import aw_core
9
9
@@ -129,27 +129,30 @@ def read_log(self) -> str:
129
129
130
130
class Manager :
131
131
def __init__ (self , testing : bool = False ) -> None :
132
- self .settings = AwQtSettings (testing )
133
- self .modules = {}
132
+ self .settings : AwQtSettings = AwQtSettings (testing )
133
+ self .modules : Dict [str , Module ] = {}
134
+ self .autostart_modules : Set [str ] = set (self .settings .autostart_modules )
135
+
134
136
for name in self .settings .possible_modules :
135
137
if _locate_executable (name ):
136
138
self .modules [name ] = Module (name , testing = testing )
137
139
else :
138
- logger .warning ("Module '{}' not found" .format (name ))
140
+ logger .warning ("Module '{}' not found but was in possible modules " .format (name ))
139
141
140
142
def get_unexpected_stops (self ):
141
- return list (filter (lambda x : x .started and not x .is_alive (), self .modules ))
143
+ return list (filter (lambda x : x .started and not x .is_alive (), self .modules . values () ))
142
144
143
145
def start (self , module_name ):
144
- if module_name in self .modules :
146
+ if module_name in self .modules . keys () :
145
147
self .modules [module_name ].start ()
146
148
147
149
def autostart (self , autostart_modules ):
148
-
149
150
if autostart_modules is None :
150
- # Modules to start are not specified. Fallback on configuration.
151
+ logger . info ( " Modules to start weren't specified in CLI arguments. Falling back to configuration." )
151
152
autostart_modules = self .settings .autostart_modules
152
153
154
+ # We only want to autostart modules that are both in found modules and are asked to autostart.
155
+ autostart_modules = autostart_modules .intersection (set (self .modules .keys ()))
153
156
# Always start aw-server first
154
157
if "aw-server" in autostart_modules :
155
158
self .start ("aw-server" )
@@ -161,7 +164,7 @@ def autostart(self, autostart_modules):
161
164
self .start (module_name )
162
165
163
166
def stop_all (self ):
164
- for module in filter (lambda m : m .is_alive (), self .modules ):
167
+ for module in filter (lambda m : m .is_alive (), self .modules . values () ):
165
168
module .stop ()
166
169
167
170
0 commit comments