@@ -281,6 +281,31 @@ def startProcess(self, name, wait=True):
281
281
@return boolean result Always true unless error
282
282
283
283
"""
284
+ # check if the process is dependent upon any other process and if so make sure that one is in the RUNNING state
285
+ group , process = self ._getGroupAndProcess (name )
286
+ if process .config .depends_on is not None :
287
+ # keep track of RUNNING childs
288
+ running_childs = set ()
289
+ # wait/loop until all childs are running
290
+ while set (process .config .depends_on .keys ()) != running_childs :
291
+ for child in process .config .depends_on .values ():
292
+ if child .get_state () != ProcessStates .RUNNING :
293
+ # potentially remove child, if it is in running list
294
+ if child .config .name in running_childs :
295
+ running_childs .remove (child .config .name )
296
+ # check if it needs to be started
297
+ if child .state is not (ProcessStates .STARTING or ProcessStates .RUNNING ):
298
+ self .startProcess (child .config .name )
299
+ else :
300
+ child .transition ()
301
+ msg = ("waiting on dependee process {} to reach running state - currently in {}"
302
+ .format (child .config .name , getProcessStateDescription (child .state )))
303
+ self .supervisord .options .logger .warn (msg )
304
+ else :
305
+ # child is running - add to set
306
+ running_childs .add (child .config .name )
307
+ time .sleep (0.5 )
308
+
284
309
self ._update ('startProcess' )
285
310
group , process = self ._getGroupAndProcess (name )
286
311
if process is None :
0 commit comments