Exemple #1
0
    async def periodical_check(self, instance: Domain):
        try:
            domain: str = instance.domain
            while instance.status in [PENDING]:
                await asyncio.sleep(5)
                # we need get fresh cache object

                instance = self.store.get_cache(domain)
                # now we need check dns propagation status
                instance.check_acme()

                if instance.continue_check:
                    acme_time = int(instance.current_time -
                                    instance.start_time)
                    if acme_time >= 60 * 11:
                        instance.status = FAILED
                        instance.on_error = "Session and confirmation timeout."

                self.store.set_cache(domain, instance, instance.cache_time_out)
                await self.store.producer_queue.put({
                    "consumer":
                    "remote.vps.agent",
                    "type":
                    "receive.json",
                    "action":
                    f"acme_{PENDING}",
                    "message":
                    instance.serialize()
                })

            # this mean domains challenge Error or Success
            # TODO add logic for this challenge
            if instance.status == SUCCESS:
                await self.store.producer_queue.put({
                    "consumer":
                    "remote.vps.agent",
                    "type":
                    "receive.json",
                    "action":
                    f"acme_{SUCCESS}",
                    "error": [],
                    "message":
                    instance.serialize()
                })
                self.store.cache.delete(domain)
            else:
                await self.store.producer_queue.put({
                    "consumer":
                    "remote.vps.agent",
                    "type":
                    "receive.json",
                    "action":
                    f"acme_{FAILED}",
                    "error": [],
                    "message":
                    instance.serialize()
                })
                self.store.cache.delete(domain)

        except Exception as exc:
            logger.exception(exc)