Skip to content

Commit e5eeae7

Browse files
author
Michael Hammann
committed
fix: make sure dependent processes also start when triggered from process which autostarts
1 parent 2c4e13c commit e5eeae7

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

supervisor/process.py

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,33 @@ def spawn(self):
195195
196196
Return the process id. If the fork() call fails, return None.
197197
"""
198+
# this section is ownly triggered when using autostart -
199+
# otherwise the dependencies are handled in the rpcinterface
200+
# check if the process is dependent upon any other process and if so,
201+
# make sure that one is in the RUNNING state
202+
if self.config.depends_on is not None:
203+
# keep track of RUNNING childs
204+
running_childs = set()
205+
# wait/loop until all childs are running
206+
while set(self.config.depends_on.keys()) != running_childs:
207+
for child in self.config.depends_on.values():
208+
if child.state is not ProcessStates.RUNNING:
209+
# potentially remove child, if it is in running list
210+
if child.config.name in running_childs:
211+
running_childs.remove(child.config.name)
212+
# check if it needs to be started
213+
if child.state is not (ProcessStates.STARTING or ProcessStates.RUNNING):
214+
child.spawn()
215+
else:
216+
child.transition()
217+
msg = ("waiting on dependee process {} to reach running state - currently in {}"
218+
.format(child.config.name, getProcessStateDescription(child.state)))
219+
self.config.options.logger.warn(msg)
220+
else:
221+
# child is running - add to set
222+
running_childs.add(child.config.name)
223+
time.sleep(0.5)
224+
198225
options = self.config.options
199226
processname = as_string(self.config.name)
200227

0 commit comments

Comments
 (0)