R
R
root092021-08-12 21:43:23
Laravel
root09, 2021-08-12 21:43:23

Laravel infinite task scheduling?

There is a table, it has records, you need to go through each record in turn and execute the function, and so on in a circle.

How can this be done through Task Scheduling or can it be some other way?

Now I created a command and call it like this $schedule->command('command:start')->everyMinute();

In it, I work with one row of the table and then run the command with the next row, and so on in a circle. But this is not an efficient method, because the function is executed for 5 seconds, and the remaining 55 seconds are idle. How can it be done otherwise?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
B
Barmunk, 2021-08-12
@Barmunk

In the desired command, add an infinite loop and there is already logic in it.

while(true) 
{
    doWork();
    sleep(1);
}

Next, feed this command to some Supervisor
[program:laravel-worker]
process_name=%(program_name)s_%(process_num)02d
command=php artisan command:start
autostart=true
autorestart=true
stopasgroup=true
killasgroup=true
user=forge
numprocs=8
redirect_stderr=true
stdout_logfile=/home/forge/app.com/worker.log
stopwaitsecs=3600

or I came across a package that does the same thing, but without
Supervisor -kak-created...

A
Anton V., 2021-08-12
@ivinnic

Similar to Queues. Maybe the Docs queue will suit you

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question