示例#1
0
 def on_process(self, event):
     """ Called when a ProcessEvent is sent by the local Supervisor.
     The event is published to all Supvisors instances. """
     event_name = events.getEventNameByType(event.__class__)
     self.logger.debug('got Process event from supervisord: {} {}'.format(event_name, event))
     # create payload from event
     payload = {'processname': event.process.config.name,
         'groupname': event.process.group.config.name,
         'state': ProcessStates._from_string(event_name.split('_')[-1]),
         'now': int(time.time()), 
         'pid': event.process.pid,
         'expected': event.expected}
     self.logger.debug('payload={}'.format(payload))
     self.publisher.send_process_event(payload)
示例#2
0
 def evaluate_conflict(self):
     """ Gets a synthetic state if several processes are in a RUNNING-like
     state. """
     if self.conflicting():
         # several processes seems to be in a running state
         # so that becomes tricky
         states = {self.infos[address]['state']
                   for address in self.addresses}
         self.logger.debug('{} multiple states {} for addresses {}'.format(
             self.process_name,
             [ProcessStates._to_string(x) for x in states],
             list(self.addresses)))
         # state synthesis done using the sorting of RUNNING_STATES
         self.state = self.running_state(states)
         return True
示例#3
0
 def on_process(self, event):
     """ Called when a ProcessEvent is sent by the local Supervisor.
     The event is published to all Supvisors instances. """
     event_name = events.getEventNameByType(event.__class__)
     self.logger.debug('got Process event from supervisord: {} {}'.format(
         event_name, event))
     # create payload from event
     payload = {'name': event.process.config.name,
         'group': event.process.group.config.name,
         'state': ProcessStates._from_string(event_name.split('_')[-1]),
         'now': int(time.time()),
         'pid': event.process.pid,
         'expected': event.expected}
     self.logger.debug('payload={}'.format(payload))
     self.publisher.send_process_event(payload)
示例#4
0
 def statename(self):
     return ProcessStates._to_string(self.statecode)
示例#5
0
 def state_string(self):
     """ Return the state as a string. """
     return ProcessStates._to_string(self.state)