def get(self): """Get the status of the manager services""" summary_response = verify_and_convert_bool( 'summary', request.args.get('summary', False)) # Systemd should be available on every manager if not get_services: return {'status': ServiceStatus.FAIL, 'services': {}} services = {} systemd_statuses = self._check_systemd_services(services) rabbitmq_status = self._check_rabbitmq(services) # Passing our authentication implies PostgreSQL is healthy self._add_or_update_service(services, 'PostgreSQL', NodeServiceStatus.ACTIVE) syncthing_status = NodeServiceStatus.ACTIVE if ha_utils and ha_utils.is_clustered(): syncthing_status = self._check_syncthing(services) status = self._get_manager_status(systemd_statuses, rabbitmq_status, syncthing_status) # If the response should be only the summary - mainly for LB if summary_response: return {'status': status, 'services': {}} return {'status': status, 'services': services}
def _verify_syncthing_status(): if not (ha_utils and ha_utils.is_clustered()): return syncthing_status, _ = get_syncthing_status() if syncthing_status == NodeServiceStatus.INACTIVE: raise manager_exceptions.FileSyncServiceError( "Can't update the status report when Syncthing is not healthy")
def _get_status_and_services(): services = {} if config.instance.service_management == 'supervisord': service_statuses = _check_supervisord_services(services) else: service_statuses = _check_systemd_services(services) rabbitmq_status = _check_rabbitmq(services) # Successfully making any query requires us to check the DB is up # (for the cope_with_db_failover logic), so we can assume postgres # is healthy if we reach here. _add_or_update_service(services, 'PostgreSQL', NodeServiceStatus.ACTIVE) if isinstance(config.instance.postgresql_host, list): services.pop('PostgreSQL') service_statuses = [service['status'] for service in services.values()] syncthing_status = NodeServiceStatus.ACTIVE if ha_utils and ha_utils.is_clustered(): syncthing_status = _check_syncthing(services) status = _get_manager_status(service_statuses, rabbitmq_status, syncthing_status) return status, services