Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create Background Processing Infrastructure: Create Status Cron Event #484

Open
Tracked by #24
bethanylang opened this issue Aug 16, 2022 · 0 comments · May be fixed by #552
Open
Tracked by #24

Create Background Processing Infrastructure: Create Status Cron Event #484

bethanylang opened this issue Aug 16, 2022 · 0 comments · May be fixed by #552
Assignees
Labels
[Focus] Images Issues related to the Images focus area [Module] Regenerate Existing Images Issues for the Regenerate Existing Images module Performance Lab Plugin Issue relates to work in the Performance Lab Plugin only

Comments

@bethanylang
Copy link
Contributor

bethanylang commented Aug 16, 2022

Create a Status Cron Event to check jobs are running correctly and remove old completed jobs.

Acceptance Criteria

Cron Schedule

  • Scheduled a new event using the wp_schedule_event function.
  • The event is scheduled with the following parameters
    • timestamp: time()
    • recurrence: hourly
    • hook: perflab_background_process_status_check

Event hook
Create a new function for the perflab_background_process_status_check hook that checks the following

Check jobs are running correctly

  • Query jobs that are currently running with get_terms
  • Retrieve running jobs by querying for terms with the job_status meta and the value running.
  • If no terms are returned continue to next check.
  • If terms are passed, loop over each term and check the following:
    • Retrieve the job_lock term meta value
    • Check the job_lock value against the ini_get( 'max_execution_time' )
    • If the job_lock meta exists and the value is less than the max_execution_time continue to the next term
    • If the job_lock meta does not exist or the value is greater the max_execution_time restart the job by calling perflab_start_background_job passing the $job_id

Remove old completed jobs

  • Query jobs that are currently running with get_terms
  • Retrieve running jobs by querying for terms with the job_status meta and the value completed.
  • If no terms are returned exit early.
  • If terms are passed, loop over each term and check the following:
    • Retrieve the job_completed_at term meta value
    • If the job_completed_at meta exists and the timestamp value is older than 7 days, the term is deleted.
@bethanylang bethanylang added [Focus] Images Issues related to the Images focus area [Module] Regenerate Existing Images Issues for the Regenerate Existing Images module labels Aug 16, 2022
@bethanylang bethanylang added this to Backlog in [Focus] Images via automation Aug 16, 2022
@ankitrox ankitrox linked a pull request Oct 6, 2022 that will close this issue
3 tasks
@felixarntz felixarntz added the Performance Lab Plugin Issue relates to work in the Performance Lab Plugin only label Jul 19, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Focus] Images Issues related to the Images focus area [Module] Regenerate Existing Images Issues for the Regenerate Existing Images module Performance Lab Plugin Issue relates to work in the Performance Lab Plugin only
Projects
3 participants