Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
while 1:
combined_map = {}
combined_map.update(socket_map)
combined_map.update(self.get_process_map())
pgroups = self.process_groups.values()
pgroups.sort()
if self.options.mood < SupervisorStates.RUNNING:
if not self.stopping:
# first time, set the stopping flag, do a
# notification and set stop_groups
self.stopping = True
self.stop_groups = pgroups[:]
events.notify(events.SupervisorStoppingEvent())
self.ordered_stop_groups_phase_1()
if not self.shutdown_report():
# if there are no unstopped processes (we're done
# killing everything), it's OK to swtop or reload
raise asyncore.ExitNow
r, w, x = [], [], []
for fd, dispatcher in combined_map.items():
if dispatcher.readable():
r.append(fd)
if dispatcher.writable():
w.append(fd)
def remove_process_group(self, name):
if self.process_groups[name].get_unstopped_processes():
return False
self.process_groups[name].before_remove()
del self.process_groups[name]
events.notify(events.ProcessGroupRemovedEvent(name))
return True
if self.options.subprocpidfile:
# 'subprocpidfile' option is set, which implies that all
# managed sub-processes should NOT be killed and would
# continue to run even supervisord exits. the supervisord
# would also continue to manage these sub-processes after
# it restarts.
self.options.logger.info('exiting without killing managed '
'sub-processes')
raise asyncore.ExitNow
if not self.stopping:
# first time, set the stopping flag, do a
# notification and set stop_groups
self.stopping = True
self.stop_groups = pgroups[:]
events.notify(events.SupervisorStoppingEvent())
self.ordered_stop_groups_phase_1()
if not self.shutdown_report():
# if there are no unstopped processes (we're done
# killing everything), it's OK to swtop or reload
raise asyncore.ExitNow
r, w, x = [], [], []
for fd, dispatcher in combined_map.items():
if dispatcher.readable():
r.append(fd)
if dispatcher.writable():
w.append(fd)
def add_process_group(self, config):
name = config.name
if name not in self.process_groups:
config.after_setuid()
self.process_groups[name] = config.make_group()
events.notify(events.ProcessGroupAddedEvent(name))
return True
return False
def runforever(self):
events.notify(events.SupervisorRunningEvent())
timeout = 1 # this cannot be fewer than the smallest TickEvent (5)
socket_map = self.options.get_socket_map()
while 1:
combined_map = {}
combined_map.update(socket_map)
combined_map.update(self.get_process_map())
pgroups = list(self.process_groups.values())
pgroups.sort()
if self.options.mood < SupervisorStates.RUNNING:
if not self.stopping:
# first time, set the stopping flag, do a
# notification and set stop_groups
def runforever(self):
events.notify(events.SupervisorRunningEvent())
timeout = 1 # this cannot be fewer than the smallest TickEvent (5)
socket_map = self.options.get_socket_map()
while 1:
combined_map = {}
combined_map.update(socket_map)
combined_map.update(self.get_process_map())
pgroups = self.process_groups.values()
pgroups.sort()
if self.options.mood < SupervisorStates.RUNNING:
if not self.stopping:
# first time, set the stopping flag, do a
# notification and set stop_groups
def run(self):
self.process_groups = {} # clear
self.stop_groups = None # clear
events.clear()
try:
for config in self.options.process_group_configs:
self.add_process_group(config)
self.options.process_environment()
self.options.openhttpservers(self)
self.options.setsignals()
if (not self.options.nodaemon) and self.options.first:
self.options.daemonize()
# writing pid file needs to come *after* daemonizing or pid
# will be wrong
self.options.write_pidfile()
self.runforever()
finally:
self.options.cleanup()
def run(self):
self.process_groups = {} # clear
self.stop_groups = None # clear
events.clear()
try:
for config in self.options.process_group_configs:
self.add_process_group(config)
self.options.process_environment()
self.options.openhttpservers(self)
self.options.setsignals()
if (not self.options.nodaemon) and self.options.first:
self.options.daemonize()
# writing pid file needs to come *after* daemonizing or pid
# will be wrong
self.options.write_pidfile()
self.runforever()
finally:
self.options.cleanup()
def __init__(self, config):
ProcessGroupBase.__init__(self, config)
self.event_buffer = []
for event_type in self.config.pool_events:
events.subscribe(event_type, self._acceptEvent)
events.subscribe(events.EventRejectedEvent, self.handle_rejected)
self.serial = -1
self.last_dispatch = 0
self.dispatch_throttle = 0 # in seconds: .00195 is an interesting one