Пример #1
0
 def supervisor(self):
     "http://supervisord.org/api.html"
     # copy from:
     # https://github.com/Supervisor/supervisor/blob/76df237032f7d9fbe80a0adce3829c8b916d5b58/supervisor/options.py#L1718
     if self._supervisorctl is None:
         self._supervisorctl = xmlrpclib.ServerProxy(
             # dumbass ServerProxy won't allow us to pass in a non-HTTP url,
             # so we fake the url we pass into it and
             # always use the transport's
             # 'serverurl' to figure out what to attach to
             "http://127.0.0.1",
             transport=xmlrpc.SupervisorTransport(
                 serverurl=f"unix://{self.data_root}/supervisor.sock"),
         )
     return self._supervisorctl.supervisor
Пример #2
0
 def __init__(self,
              stdin,
              stdout,
              server_url,
              event_handlers,
              update_process_list=False):
     self._stdin = stdin
     self._stdout = stdout
     # ServerProxy won't allow us to pass in a non-HTTP url,
     # so we fake the url we pass into it and always use the transport's
     # 'serverurl' to figure out what to attach to
     self._proxy = xmlrpclib.ServerProxy(
         'http://127.0.0.1',
         transport=xmlrpc.SupervisorTransport(serverurl=server_url))
     self._event_listener = SupervisorEventListener()
     self._event_handlers = event_handlers
     self._update_process_list = update_process_list
Пример #3
0
total = {
    "STOPPED": 0,
    "STARTING": 0,
    "RUNNING": 0,
    "BACKOFF": 0,
    "STOPPING": 0,
    "EXITED": 0,
    "FATAL": 0,
    "UNKNOWN": 0,
}

try:
    server = ServerProxy(
        "http://127.0.0.1",
        transport=xmlrpc.SupervisorTransport(None, None,
                                             "unix://" + unix_socket_path),
    )

    state = server.supervisor.getState()["statename"]

    if state != "RUNNING":
        error = 1
        error_string = "Not running"

    for process in server.supervisor.getAllProcessInfo():
        if process["statename"] == "RUNNING":
            uptime = process["now"] - process["start"]
        else:
            uptime = process["stop"] - process["start"]

        uptime = 0 if uptime < 0 else uptime
Пример #4
0
def get_supervisor_proxy():
    proxy = xmlrpclib.ServerProxy('http://' + settings.INTERNAL_IPS[0],
                                  transport=xmlrpc.SupervisorTransport(
                                      None, None, 'unix://' +
                                      settings.SUPERVISOR_UNIX_SOCKET_FILE))
    return proxy