Help integrating multiple infinite tasks to django

I’m currently building a server monitoring application and I’m trying to integrate a script that creates asyncio tasks to check the status of specific hosts. For now I have a task that checks if a port is open and another one that pings the host with ICMP. If successful, they sleep for a specific duration (default 60 seconds) and repeat the same process, but if they fail they send an email to a specific address.

The script functions well on it’s own but I would like to create a website from which I can start and stop these tasks. However, I’m unsure on where or how I should integrate this within Django.

If anyone has any guidance or suggestions thanks in advance!

I would keep your monitoring application as a separate and independent process from your Django project.

That creates this as an “IPC” issue - how to get the two services to talk to each other.

You could create an HTTP listener as another async task in your monitoring application, creating a REST-style API that the Django project accesses using the requests module.

Or, the way that I currently do this, you can use redis as a two-way message queue.

If the two projects are going to share a database and models, you could also use Channels as an IPC mechanism on top of redis. That would have some value if there are shared components between the two.