@@ -213,21 +213,21 @@ async def prepare(self) -> bool:
213213 return await super ().prepare ()
214214
215215 async def startup (self ) -> bool :
216- await super ().startup ()
217216 if self .config .get ('autostart' , True ):
218217 self .log .debug (f"Launching SRS server with: \" { self .get_exe_path ()} \" -cfg=\" { self .config ['config' ]} \" " )
219- if sys .platform == 'win32' and self .config .get ('minimized' , True ):
220- import win32process
221- import win32con
222-
223- info = subprocess .STARTUPINFO ()
224- info .dwFlags |= win32process .STARTF_USESHOWWINDOW
225- info .wShowWindow = win32con .SW_SHOWMINNOACTIVE
226- else :
227- info = None
228- out = subprocess .DEVNULL if not self .config .get ('debug' , False ) else None
229218
230219 def run_subprocess ():
220+ if sys .platform == 'win32' and self .config .get ('minimized' , True ):
221+ import win32process
222+ import win32con
223+
224+ info = subprocess .STARTUPINFO ()
225+ info .dwFlags |= win32process .STARTF_USESHOWWINDOW
226+ info .wShowWindow = win32con .SW_SHOWMINNOACTIVE
227+ else :
228+ info = None
229+ out = subprocess .DEVNULL if not self .config .get ('debug' , False ) else None
230+
231231 return subprocess .Popen ([
232232 self .get_exe_path (),
233233 f"-cfg={ os .path .expandvars (self .config ['config' ])} "
@@ -241,7 +241,14 @@ def run_subprocess():
241241 except psutil .NoSuchProcess :
242242 self .log .error (f"Error during launch of { self .get_exe_path ()} !" )
243243 return False
244- return await asyncio .to_thread (self .is_running )
244+ # Give SRS 10s to start
245+ for _ in range (0 , 10 ):
246+ if self .is_running ():
247+ break
248+ await asyncio .sleep (1 )
249+ else :
250+ return False
251+ return await super ().startup ()
245252
246253 def shutdown (self ) -> bool :
247254 if self .config .get ('autostart' , True ) and not self .config .get ('no_shutdown' , False ):
@@ -336,6 +343,8 @@ def is_running(self) -> bool:
336343 if not self .process :
337344 self .process = utils .find_process ('SR-Server.exe' , self .server .instance .name )
338345 running = self .process is not None and self .process .is_running ()
346+ if not running :
347+ self .log .debug ("SRS: is NOT running (process)" )
339348 else :
340349 try :
341350 server_ip = self .locals ['Server Settings' ].get ('SERVER_IP' , '127.0.0.1' )
@@ -347,6 +356,8 @@ def is_running(self) -> bool:
347356 f"It does not contain a valid IP-address!" )
348357 server_ip = '127.0.0.1'
349358 running = utils .is_open (server_ip , self .locals ['Server Settings' ].get ('SERVER_PORT' , 5002 ))
359+ if not running :
360+ self .log .debug ("SRS: is NOT running (port)" )
350361 # start the observer, if we were started to a running SRS server
351362 if running and not self .observer :
352363 self .start_observer ()
0 commit comments