Exemplo n.º 1
0
 def _rpc_status(self, msg):
     return protocols.pack(protobuf.ReaperStatusResponse, {'status': 'OK'})
Exemplo n.º 2
0
 def _rpc_shutdown(self, msg):
     response = protocols.pack(protobuf.ReaperStatusResponse, {'status': 'shutdown'})
     self.shutdown(delay=1)
     return response
Exemplo n.º 3
0
                response.error = False
            except Exception, e:
                #self.logger.error("Error in command '%s': %s %s" % (request.method, str(Exception),  e))
                sys.excepthook(*sys.exc_info())
                #traceback.print_tb(sys.last_traceback)
                response.payload = ''
                response.error = True
                response.error_string = str(e)
        else:
            self.logger.error("Invalid Command: %s" % request.method)
            response.payload = None
            response.error = True
            response.error_text = "Invalid Command: %s" % request.method

        self.control_listener.channel.basic_ack(msg.delivery_tag)
        response_bytes = protocols.pack(protobuf.RpcResponseWrapper, response)
        self.control_listener.channel.basic_publish(Message(response_bytes), routing_key=request.requestor)
        self.logger.debug("Sent response to a control command (%s)" % request.method)

    def register_with_dispatch(self):
        import socket
        hostname = socket.gethostname()
        del socket
        
        if self.dispatch.register_reaper(self.reaper_id, self.REAPER_TYPE, hostname=hostname):
            self.logger.info("Registration successful")
            self.is_registered = True
        else:
            self.logger.error("Registration FAILED.")
            self.shutdown()