Skip to content

Instantly share code, notes, and snippets.

@jalp
Created March 25, 2014 08:32
Show Gist options
  • Save jalp/9757351 to your computer and use it in GitHub Desktop.
Save jalp/9757351 to your computer and use it in GitHub Desktop.
Supervisor client
import xmlrpclib
class SupervisorClient(object):
""" Supervisor client to work with remote supervisor
"""
def __init__(self, host='localhost', port=9001):
self.server = xmlrpclib.Server('http://{}:{}/RPC2'.format(host, port))
def _generate_correct_process_name(self, process):
return "{}:1".format(process)
def start(self, process):
""" Start process
:process: process name as String
"""
return self.server.supervisor.startProcess(self._generate_correct_process_name(process))
def stop(self, process):
""" Stop process
:process: process name as String
"""
return self.server.supervisor.stopProcess(self._generate_correct_process_name(process))
def status(self, process):
""" Retrieve status process
:process: process name as String
"""
return self.server.supervisor.getProcessInfo(self._generate_correct_process_name(process))['statename']
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment