How to use the supervisor.childutils function in supervisor

To help you get started, we’ve selected a few supervisor examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github Supervisor / superlance / superlance / process_state_monitor.py View on Github external
def run(self):
        while 1:
            hdrs, payload = childutils.listener.wait(self.stdin, self.stdout)
            self.handle_event(hdrs, payload)
            childutils.listener.ok(self.stdout)
github Supervisor / supervisor / supervisor / scripts / loop_eventgen.py View on Github external
def main(max):
    start = time.time()
    report = open('/tmp/report', 'w')
    i = 0
    while 1:
        childutils.pcomm.stdout('the_data')
        sys.stdin.readline()
        report.write(str(i) + ' @ %s\n' % childutils.get_asctime())
        report.flush()
        i+=1
        if max and i >= max:
            end = time.time()
            report.write('%s per second\n' % (i / (end - start)))
            sys.exit(0)
github vovanec / supervisor_checks / supervisor_checks / check_runner.py View on Github external
def _wait_for_supervisor_event(self):
        """Wait for supervisor events.
        """

        childutils.listener.ready(sys.stdout)

        while not self._stop_event.is_set():
            try:
                rdfs, _, _ = select.select([sys.stdin], [], [], .5)
            except InterruptedError:
                continue

            if rdfs:
                headers = childutils.get_headers(rdfs[0].readline())
                # Read the payload to make read buffer empty.
                _ = sys.stdin.read(int(headers['len']))
                event_type = headers[EVENT_NAME_KEY]
                self._log('Received %s event from supervisor', event_type)

                return event_type
github XiaoMi / minos / supervisor / superlance / crashmailbatch.py View on Github external
def get_process_state_change_msg(self, headers, payload):
        pheaders, pdata = childutils.eventdata(payload+'\n')

        if int(pheaders['expected']):
            return None

        self.add_customized_mail_list(pheaders)
        txt = 'Process %(groupname)s:%(processname)s (pid %(pid)s) died \
unexpectedly' % pheaders
        return '%s -- http://%s:%d -- %s' % (childutils.get_asctime(self.now),
            self.local_ip, self.supervisord_port, txt)
github Supervisor / superlance / superlance / crashmailbatch.py View on Github external
def get_process_state_change_msg(self, headers, payload):
        pheaders, pdata = childutils.eventdata(payload+'\n')

        if int(pheaders['expected']):
            return None

        txt = 'Process %(groupname)s:%(processname)s (pid %(pid)s) died \
unexpectedly' % pheaders
        return '%s -- %s' % (childutils.get_asctime(self.now), txt)
github flashashen / no-YOU-talk-to-the-hand / no_you_talk_to_the_hand.py View on Github external
@cli.command('stop')
def stop():
    """
    Stop daemon along with any tunnels that are running
    """
    try:
        childutils.getRPCInterface({'SUPERVISOR_SERVER_URL':'unix:///tmp/vpnsupervisor.sock'}).supervisor.shutdown()
    except Exception as e:
        if not 'No such' in str(e):
            raise
        else:
            print 'Supervisor does not appear to be running'
            return

    print('Supervisor stopped')
github vovanec / supervisor_checks / supervisor_checks / check_runner.py View on Github external
def _wait_for_supervisor_event(self):
        """Wait for supervisor events.
        """

        childutils.listener.ready(sys.stdout)

        while not self._stop_event.is_set():
            try:
                rdfs, _, _ = select.select([sys.stdin], [], [], .5)
            except InterruptedError:
                continue

            if rdfs:
                headers = childutils.get_headers(rdfs[0].readline())
                # Read the payload to make read buffer empty.
                _ = sys.stdin.read(int(headers['len']))
                event_type = headers[EVENT_NAME_KEY]
                self._log('Received %s event from supervisor', event_type)

                return event_type

        raise AboutToShutdown