Example #1
0
    def __call__(self, process_spec):

        try:
            port = utils.get_port(self._config['port'], process_spec['name'])
            return self._http_check(process_spec['name'], port)
        except errors.InvalidPortSpec:
            self._log('ERROR: Could not extract the HTTP port for process '
                      'name %s using port specification %s.',
                      process_spec['name'], self._config['port'])

            return True
        except Exception as exc:
            self._log('Check failed: %s', exc)

        return False
Example #2
0
    def __call__(self, process_spec):

        try:
            port = utils.get_port(self._config['port'], process_spec['name'])
            return self._http_check(process_spec['name'], port)
        except errors.InvalidPortSpec:
            self._log('ERROR: Could not extract the HTTP port for process '
                      'name %s using port specification %s.',
                      process_spec['name'], self._config['port'])

            return True
        except Exception as exc:
            self._log('Check failed: %s', exc)

        return False
Example #3
0
    def __call__(self, process_spec):

        timeout = self._config.get('timeout', DEFAULT_TIMEOUT)
        num_retries = self._config.get('num_retries', DEFAULT_RETRIES)

        try:
            port = utils.get_port(self._config['port'], process_spec['name'])
            with utils.retry_errors(num_retries, self._log).retry_context(
                    self._tcp_check) as retry_tcp_check:
                return retry_tcp_check(process_spec['name'], port, timeout)
        except errors.InvalidPortSpec:
            self._log('ERROR: Could not extract the HTTP port for process '
                      'name %s using port specification %s.',
                      process_spec['name'], self._config['port'])

            return True
        except Exception as exc:
            self._log('Check failed: %s', exc)

        return False
Example #4
0
    def __call__(self, process_spec):

        timeout = self._config.get('timeout', DEFAULT_TIMEOUT)
        num_retries = self._config.get('num_retries', DEFAULT_RETRIES)

        try:
            port = utils.get_port(self._config['port'], process_spec['name'])
            with utils.retry_errors(num_retries, self._log).retry_context(
                    self._tcp_check) as retry_tcp_check:
                return retry_tcp_check(process_spec['name'], port, timeout)
        except errors.InvalidPortSpec:
            self._log(
                'ERROR: Could not extract the TCP port for process '
                'name %s using port specification %s.', process_spec['name'],
                self._config['port'])

            return True
        except Exception as exc:
            self._log('Check failed: %s', exc)

        return False
Example #5
0
    def _get_server_url(self, process_name):
        """Construct XML RPC server URL.

        :param str process_name: process name.
        :rtype: str|None
        """

        url = self._config.get('url')

        if url:
            try:
                port = utils.get_port(self._config['port'], process_name)

                return 'http://%s:%s%s' % (LOCALHOST, port, url)
            except errors.InvalidPortSpec:
                self._log(
                    'ERROR: Could not extract the HTTP port for '
                    'process name %s using port specification %s.',
                    process_name, self._config['port'])
        else:
            sock_path = self._config.get('sock_path')

            if not sock_path:
                sock_dir = self._config.get('sock_dir')

                if not sock_dir:
                    self._log('ERROR: Could not construct XML RPC socket '
                              'path using configuration provided. sock_dir '
                              'or sock_path argument must be specified.')
                    return None

                sock_path = 'unix://%s/%s.sock' % (
                    sock_dir,
                    process_name,
                )

            if not sock_path.startswith('unix://'):
                sock_path = 'unix://%s' % (sock_path, )

            return sock_path
Example #6
0
    def _get_server_url(self, process_name):
        """Construct XML RPC server URL.

        :param str process_name: process name.
        :rtype: str|None
        """

        url = self._config.get('url')

        if url:
            try:
                port = utils.get_port(self._config['port'],
                                      process_name)

                return 'http://%s:%s%s' % (LOCALHOST, port, url)
            except errors.InvalidPortSpec:
                self._log('ERROR: Could not extract the HTTP port for '
                          'process name %s using port specification %s.',
                          process_name, self._config['port'])
        else:
            sock_path = self._config.get('sock_path')

            if not sock_path:
                sock_dir = self._config.get('sock_dir')

                if not sock_dir:
                    self._log('ERROR: Could not construct XML RPC socket '
                              'path using configuration provided. sock_dir '
                              'or sock_path argument must be specified.')
                    return None

                sock_path = 'unix://%s/%s.sock' % (sock_dir, process_name,)

            if not sock_path.startswith('unix://'):
                sock_path = 'unix://%s' % (sock_path,)

            return sock_path