Created
March 25, 2014 08:32
-
-
Save jalp/9757351 to your computer and use it in GitHub Desktop.
Supervisor client
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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