deliciousbrains / wp-background-processing

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

Have to declare handle_cron_healthcheck() for it to process #34

Closed calebsmithdev closed 1 year ago

calebsmithdev commented 7 years ago

I've been having some issues with the Background process calling handle and activating the cron schedules needed for the fallback. Right now, I am utilizing something I saw in WooCommerce to force a healthcheck, which will start the handle process. I have also hooked that into the heartbeat function to continue polling for background processes, in the event the original timesout. This code starts the process, and this code is where I declare the handle_cron_healthcheck().

Is there a better way to make sure the background process has started? I want this to be pretty painless, from a user perspective, but I also want to make sure I understand what I am doing!

Really appreciate the help and for creating this awesome batch of code! I was really bummed when I moved from a Laravel project to a WP project and lost my queue process.

dskvr commented 7 years ago

@Failcookie accidentally published the same link twice, the second link in his issue was intended to link to this line

I too have this issue. When I attempted handle_cron_healthcheck() I finally got a task to fire successfully, but the server throws a 500.

leewillis77 commented 7 years ago

Not sure if it's relevant here - however it seems that you can get issues with the heartbeat getting called in certain cases:

I've hit all three of these on a project - although it's legacy code and is a bit of a rats nest of timing and dependencies so some of the above may be down to that in part. May help you though!

derchecker07 commented 1 year ago

If your job classes get instantiated after the cron_schedules filter has fired [In which case the frequency doesn't get registered so the queueing of the healthcheck fails]

@leewillis77 After multiple hours of trial and error, this part of your comment finally helped me fix my issue. I was instantiating my background-process-class only when the user clicked a specific button in the WP Admin UI and, as it turns out, this was way too late. Moving the instantiation to the "plugins_loaded" hook solved my issue - thank you very much! 🎉

ianmjones commented 1 year ago

Closing ancient issue. :smile: