Hey o1. Could you rewrite my health checking class so it's simpler, and that I can invoke the background monitoring using my apscheduler instead of asyncio?

<code>
```python
lass Scheduler:
    __instance = None

    @staticmethod
    def get_instance():
        if Scheduler.__instance is None:
            Scheduler.__instance = BackgroundScheduler()
            Scheduler.__instance.start()
        return Scheduler.__instance

    @staticmethod
    def schedule_task(func, trigger, args, id):
        scheduler = Scheduler.get_instance()
        scheduler.add_job(func, trigger, args=args, id=id)

    @staticmethod
    def cancel_task(id):
        scheduler = Scheduler.get_instance()
        scheduler.remove_job(id)

class HealthChecker:
    def __init__(self, check_interval=60):
        self.endpoints = {
            "db": "<to be filled>/db",
            "wp": "<to be filled>/wp",
            "api": "<to be filled>/api",
        }
        self.check_interval = check_interval
        self.is_healthy = False

    async def check_endpoint(self, name, url):
        for _ in range(2):  # 
            print(f"checking {name} {url}")
            try:
                data = authmee_get_token(url)
               # print(f"{data}")
                if data['is_healthy'] == True:
                    return True
            except Exception as e:
                print(e)
                pass
            await asyncio.sleep(1)  # delay
      #  await self.send_health_notification(name, False)
        return False

    async def check_health(self):
        for name, url in self.endpoints.items():
            if not await self.check_endpoint(name, url):
                self.is_healthy = False
                return False
        self.is_healthy = True
        return True

    async def monitor_health(self):
        while True:
            print("checking!")
            await self.check_health()
            await asyncio.sleep(self.check_interval)
        
    async def send_health_notification(self, endpoint: str, is_healthy: bool):
         status = "restored" if is_healthy else "down"
         message = f"{endpoint} health is {status}"
         await asyncio.to_thread(mail, message, f"{endpoint}_health", is_healthy, privileged=True)


class Parser:
    def __init__(self):
        self.event_fetcher = EventFetcher()
        self.event_handler = EventHandler()
        self.running = True
        self.health_checker = HealthChecker()


    async def receiver(self, url: str, parser_debug: bool):
        
        if not parser_debug: 
            if self.health_checker.is_healthy:
                data = await self.event_fetcher.fetch_event(url)
                if data:
                    try:
                        event = Event(
                            data["id"],
                            data["description"],
                            data["device_id"],
                            bool(data["alert_state"]),
                        )
                        await self.event_handler.handle_event(event)
                    except Exception as e:
                        print(f"Error handling event: {e}")
                else:
                    print("None returned")
        else:
            await asyncio.to_thread(mail, "power lost", "power_outage", True)
            self.running = False
            Scheduler.cancel_scheduler()
       

    async def run(self, parser_debug: bool = False, health_debug: bool = False):
        health_task = asyncio.create_task(self.health_checker.monitor_health())

        while True: 
            if not health_debug:
                while self.running:
                    if self.health_checker.is_healthy:
                        await self.receiver("http://127.0.0.1:8000/event", parser_debug)
                    await asyncio.sleep(1)
                health_task.cancel()
            else:
                await self.count_seconds


    async def count_seconds():
        for second in range(1, 61):
            print(f"Second: {second}\n")
            await asyncio.sleep(1)


    def stop(self):
        self.running = False
        Scheduler.cancel_scheduler()


async def main():
    parser = Parser()

    def signal_handler():
        parser.stop()

    for sig in (signal.SIGINT, signal.SIGTERM):
        loop.add_signal_handler(sig, signal_handler)

    try:
       await parser.run(False, True)
    finally:
        print("Shutting down...")



if __name__ == "__main__":
    loop = asyncio.new_event_loop()
    asyncio.set_event_loop(loop)
    try:
        loop.run_until_complete(main())
    finally:
        loop.close()
</code>