Check to see if the job has been running more then 3 hours#126
Check to see if the job has been running more then 3 hours#126stuartshields wants to merge 1 commit intomasterfrom
Conversation
| // Check if the job is running more then 3 hours from the timestamp. | ||
| $is_delete_running = ( time() - $job->start ) > 10800; | ||
| if ( $is_delete_running ) { | ||
| $job->delete( [ 'delete_running' => $is_delete_running ] ); |
There was a problem hiding this comment.
Rather than being this opinionated in the Cavalcade code itself, could we introduce a filter cavalcade/job-max-runtime which defaults to false, but lets a project opt in to this behavior when set?
There was a problem hiding this comment.
The issue when I try to fix this on another project was, if the job is running status and stalled, it cannot be deleted from wp_unschedule_event triggered from cron delete from cli.
Although I agree on the max time out is up to project to decide.
|
I don't want to make specific assumptions in Cavalcade itself about the run time of jobs or similar, as it's designed to be generic infrastructure; a 3 hour job could be normal in the context of a particular site. From what I see here, the issue is that Crontrol doesn't have any ability to "force" deletion, which kind of makes sense there. If a job is actually currently running, what does it mean to cancel it? Would we need to kill the process? (And what implications does that have for the partially-completed job?) Ideally, if we could lift this functionality up, that seems like the best option; i.e. add into the Crontrol UI the distinction. This would allow per-project discretion, while also making it clear to the user what the implications are. |
When a job is stuck (long running jobs) it makes it hard to delete the job when using plugins like WP Crontrol.
This PR is based on a solution that has been tested and is being used on an existing project that allows for us to delete these jobs via WP Control.
Props: @ivankristianto