-
Notifications
You must be signed in to change notification settings - Fork 270
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
Detect dead jobs and set to 'failed' status #806
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -566,6 +566,9 @@ public static function wp2staticManuallyEnqueueJobs() : void { | |
earlier jobs of the same type having been "squashed" first | ||
*/ | ||
public static function wp2staticProcessQueue() : void { | ||
global $wpdb; | ||
|
||
JobQueue::markFailedJobs(); | ||
// skip any earlier jobs of same type still in 'waiting' status | ||
JobQueue::squashQueue(); | ||
|
||
|
@@ -609,11 +612,21 @@ public static function wp2staticProcessQueue() : void { | |
WsLog::l( 'No deployment add-ons are enabled, skipping deployment.' ); | ||
} else { | ||
WsLog::l( 'Starting deployment' ); | ||
do_action( | ||
'wp2static_deploy', | ||
ProcessedSite::getPath(), | ||
$deployer | ||
); | ||
$query = "SELECT GET_LOCK('wp2static_jobs_deploying', 30) AS lck"; | ||
$locked = intval( $wpdb->get_row( $query )->lck ); | ||
if ( ! $locked ) { | ||
WsLog::l( 'Failed to acquire "wp2static_jobs_deploying" lock.' ); | ||
return; | ||
} | ||
try { | ||
do_action( | ||
'wp2static_deploy', | ||
ProcessedSite::getPath(), | ||
$deployer | ||
); | ||
} finally { | ||
$wpdb->query( "DO RELEASE_LOCK('wp2static_jobs_deploying')" ); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If this ever fails, do we have a way to manually clean up, like with caches? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In testing, releasing here was not even necessary because WP apparently closes the connection after the request, which implicitly releases the locks. If we ever run into a problem with a customized WP or something, we can add a config option to turn this off. |
||
} | ||
} | ||
WsLog::l( 'Starting post-deployment actions' ); | ||
do_action( 'wp2static_post_deploy_trigger', $deployer ); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will this still let registered post deployment hooks fire? ie, if S3 deploy fails and we return here, might it still call CF invalidation unnecessarily?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, we're not catching the exceptions so it will not run post-deploy hooks in that case.