I want to make an uptime control application with Laravel.
New sites will be added to the database constantly.
Each site will be thoroughly checked. Whether the site is online or not, when was it interrupted, how long did it take to go online, etc. I will store such details in the database.
No problem so far, I can do these. I wanted to explain these parts to explain better.
However, I am stuck on how to make a background service through laravel.
For example, if I were doing this with plain php, I would create a service for linux and run it with "systemctl start foo", with the command "systemctl enable foo" I would always make it run. I would create a php file and it could run forever in a "while" loop. or I could use nohup or supervisor.
But I don't want to go this way. This is a framework and I want to move forward in that direction.
I did a lot of research but couldn't find a solution. There is a laravel queue way for some operations, but that's not exactly what I want. For this to work, we add it to the queue with the "dispatch" method and run the processes in the queue with the "php artisan queue:work" command. We use supervisor for continuous operation.
But in my case there is no "dispatch" trigger. There is a constant listening to the database and running a transaction.
I created a command with "php artisan make:command foo" and I run a command with "php artisan foo" it works ok.
But how can I run it continuously, is there a way around this? Should I go outside the framework?
If I can resolve this issue without leaving the framework, is there a way to monitor them on the frontend? (websocket etc. external)
Because I plan to run other services in the background and it would be great to be able to view their current status, uptime, network usage and output.
Or a small idea that comes to my mind, I will start the first process manually (I will manually add it to the queue via dispatch and run the queue on the supervisor side). When the first transaction is completed, it will send the next site to Jobs via dispatch. but it doesn't seem like a very healthy way.