Verified Commit ea37320c authored by Erick Hitter's avatar Erick Hitter
Browse files

Simplify command so that there will be one subcommand per lock

parent dd2c1d63
......@@ -7,17 +7,33 @@ namespace Automattic\WP\Cron_Control\CLI;
*/
class Lock extends \WP_CLI_Command {
/**
* Check value of execution lock
* Manage the lock that limits concurrent job executions
*
* Not to exceed `JOB_CONCURRENCY_LIMIT`
*
* @subcommand check-run-lock
* @subcommand run-lock
* @synopsis [--reset]
*/
public function check_run_lock( $args, $assoc_args ) {
public function run_lock( $args, $assoc_args ) {
// Output information about the lock
\WP_CLI::line( __( 'This lock limits the number of concurrent events that are run.', 'automattic-cron-control' ) . "\n" );
\WP_CLI::line( sprintf( __( 'Maximum: %s', 'automattic-cron-control' ), number_format_i18n( \Automattic\WP\Cron_Control\JOB_CONCURRENCY_LIMIT ) ) . "\n" );
// Reset requested
if ( isset( $assoc_args['reset'] ) ) {
\WP_CLI::warning( __( 'Resetting lock', 'automattic-cron-control' ) . "\n" );
$lock = \Automattic\WP\Cron_Control\Lock::get_lock_value( \Automattic\WP\Cron_Control\Events::LOCK );
$timestamp = \Automattic\WP\Cron_Control\Lock::get_lock_timestamp( \Automattic\WP\Cron_Control\Events::LOCK );
\WP_CLI::line( sprintf( __( 'Previous value: %s', 'automattic-cron-control' ), number_format_i18n( $lock ) ) );
\WP_CLI::line( sprintf( __( 'Previous lock expiration: %s GMT', 'automattic-cron-control' ), date( TIME_FORMAT, $timestamp ) ) . "\n" );
\Automattic\WP\Cron_Control\Lock::reset_lock( \Automattic\WP\Cron_Control\Events::LOCK );
\WP_CLI::success( __( 'Lock reset', 'automattic-cron-control' ) . "\n" );
\WP_CLI::line( __( 'New lock values:', 'automattic-cron-control' ) );
}
// Output lock state
$lock = \Automattic\WP\Cron_Control\Lock::get_lock_value( \Automattic\WP\Cron_Control\Events::LOCK );
$timestamp = \Automattic\WP\Cron_Control\Lock::get_lock_timestamp( \Automattic\WP\Cron_Control\Events::LOCK );
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment