deliciousbrains / wp-background-processing

WordPress background processing class
GNU General Public License v2.0
1.05k stars 162 forks source link

Background process pauses between chunks (not desired) #118

Open nine-2-five opened 3 months ago

nine-2-five commented 3 months ago

I'm sending chunks of 1000 filenames to queue and have two issues:

  1. the process doesn't start immediately
  2. the process pauses between chunks and reschedules some minutes in the future

Is there a way to start the process immediately and have it running without rescheduling until finished?

foreach ($archives as $archive_name => $archive) {
            foreach ($archive as $chunk) {
                $task = [
                    "backup_id" => $backup_id,
                    "archive_name" => $archive_name,
                    "chunk" => $chunk,
                ];
                $this->processor->push_to_queue($task);
            }
        }

$this->processor->save()->dispatch();

/* I've tried this to start it right away */
wp_remote_get(site_url('wp-cron.php?doing_wp_cron'));

Update:

my plugin seems to work fine on another server under Apache, the problem I reported here presents itself when running on a developer machine under docker image wordpress:6-php8.1-fpm.

It seems the task() method is called every 5th call to wp-cron.php, or every 5 minutes.

nine-2-five commented 3 months ago

It was a complication related to loopback request error because I'm running Docker in WSL, and the hosts file has the 127.0.0.1 IP of the test site domain for development purposes, so I mangled up a script to get the nginx IP during wordpress-fpm container start and place that in the /etc/hosts file of the wordpress-fpm container.