How to use the supervisor.childutils.getRPCInterface 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 / supervisor / supervisor / scripts / loop_listener.py View on Github external
def main():
    rpcinterface = childutils.getRPCInterface(os.environ)
    while 1:
        headers, payload = childutils.listener.wait()
        if headers['eventname'].startswith('PROCESS_COMMUNICATION'):
            pheaders, pdata = childutils.eventdata(payload)
            pname = '%s:%s' % (pheaders['processname'], pheaders['groupname'])
            rpcinterface.supervisor.sendProcessStdin(pname, 'Got it yo\n')
        childutils.listener.ok()
github Supervisor / supervisor / src / supervisor / scripts / osx_memmon_listener.py View on Github external
def main(maxkb):
    rpc = childutils.getRPCInterface(os.environ)
    while 1:
        headers, payload = childutils.listener.wait()
        if headers['eventname'].startswith('PROCESS_COMMUNICATION'):
            pheaders, pdata = childutils.eventdata(payload)
            procname, groupname = pheaders['processname'], pheaders['groupname']
            if groupname == 'monitor':
                for event, elem in etree.iterparse(StringIO(pdata)):
                    if elem.tag == 'process':
                        rss = int(elem.find('rss').text)
                        name = elem.attrib['name']
                        if  rss > maxkb:
                            rpc.supervisor.stopProcess(name)
                            rpc.supervisor.startProcess(name)
        childutils.listener.ok()
github flashashen / no-YOU-talk-to-the-hand / no_you_talk_to_the_hand.py View on Github external
def get_supervisor():
    return childutils.getRPCInterface({'SUPERVISOR_SERVER_URL':'unix:///tmp/vpnsupervisor.sock'}).supervisor
github borntyping / supermann / supermann / supervisor / client.py View on Github external
def XMLRPCClient():
    """Returns an XML-RPC client built from Supervisor's environment"""
    return supervisor.childutils.getRPCInterface(os.environ)
github vovanec / supervisor_checks / supervisor_checks / check_runner.py View on Github external
def _restart_process(self, process_spec):
        """Restart a process.
        """

        name_spec = make_namespec(
            process_spec[GROUP_KEY], process_spec[NAME_KEY])

        rpc_client = childutils.getRPCInterface(self._environment)

        process_spec = rpc_client.supervisor.getProcessInfo(name_spec)
        if process_spec[STATE_KEY] is ProcessStates.RUNNING:
            self._log('Trying to stop process %s', name_spec)

            try:
                rpc_client.supervisor.stopProcess(name_spec)
                self._log('Stopped process %s', name_spec)
            except xmlrpclib.Fault as exc:
                self._log('Failed to stop process %s: %s', name_spec, exc)

            try:
                self._log('Starting process %s', name_spec)
                rpc_client.supervisor.startProcess(name_spec, False)
            except xmlrpclib.Fault as exc:
                self._log('Failed to start process %s: %s', name_spec, exc)
github Supervisor / supervisor / src / supervisor / scripts / osx_memmon_eventgen.py View on Github external
def main(every):
    rpc = childutils.getRPCInterface(os.environ)
    while 1:
        infos = rpc.supervisor.getAllProcessInfo()
        result = do(infos)
        childutils.pcomm.stdout(result)
        time.sleep(every)