Ejemplo n.º 1
0
 def __init__(self):
     self.__acl = ACL()
     self.__option_entity = OptionEntity()
     self.__user_entity = UserEntity()
     self.__notification_entity = NotificationEntity()
     self.__register_request_entity = RegisterRequestEntity()
     self.__task_core = TaskCore()
Ejemplo n.º 2
0
    def check_workers(self):
        errors = []
        task_core = TaskCore()
        task_core.delete_old_tasks_by_executor(
            "app.tasks.ping.ping",
            int(os.getenv("DELETE_PING_TASK_AFTER_MINUTES", 1)))
        tasks = task_core.get_many_by_executor("app.tasks.ping.ping")

        for task in tasks:
            if task.status != "passed" and task.created_at < make_aware(
                    datetime.now() - timedelta(seconds=int(
                        os.getenv("WORKERS_CALM_DOWN_SECONDS", 30)))):
                errors.append(
                    _("Error: celery workers not performing well or down.") %
                    {"task_id": task.id})

        if len(tasks) == 0:
            try:
                task_core.delay("ping", {"text": "PONG"}, None)
            except Exception as e:
                errors.append(
                    _("Error while creating a ping task: %(error)s") %
                    {"error": str(e)})

        return errors
Ejemplo n.º 3
0
    def __init__(self):
        self.__reset_request_entity = ResetRequestEntity()
        self.__option_entity = OptionEntity()
        self.__user_entity = UserEntity()
        self.__task_core = TaskCore()

        messages_count_option = self.__option_entity.get_one_by_key(
            "reset_mails_messages_count")
        reset_expire_option = self.__option_entity.get_one_by_key(
            "reset_mails_expire_after")

        if messages_count_option:
            self.__messages_count_option = int(messages_count_option.value)

        if reset_expire_option:
            self.__reset_expire_option = int(reset_expire_option.value)
Ejemplo n.º 4
0
    def get(self, request, type):

        self.__prometheus = Prometheus()
        self.__statistics = StatisticsModule()

        TaskCore().delay("ping", {
            "text": "HelloWorld",
            "correlation_id": self.correlation(request)
        }, 1)

        if type not in ("prometheus"):
            raise Http404("Page not found.")

        if type == "prometheus":

            self.__prometheus.set_metrics([
                self.__statistics.get_all_users(),
                self.__statistics.get_all_profiles(),
                self.__statistics.get_all_tasks()
            ])

            return HttpResponse(self.__prometheus.get_plain_metrics(), content_type='text/plain')