Commit af244774 authored by Erick Hitter's avatar Erick Hitter
Browse files

Add logic to runner to be disabled from PHP

Since this is meant to run as a service, sites should be able to flag themselves as disabled.
parent 3eebe912
......@@ -72,15 +72,13 @@ class Orchestrate extends \WP_CLI_Command {
array(
'multisite' => is_multisite() ? 1 : 0,
'siteurl' => site_url(),
'disabled' => 0,
),
);
$format = \WP_CLI\Utils\get_flag_value( $assoc_args, 'format', 'table' );
\WP_CLI\Utils\format_items( $format, $info, array(
'multisite',
'siteurl',
) );
\WP_CLI\Utils\format_items( $format, $info, array_keys( $info[0] ) );
}
}
......
......@@ -15,6 +15,7 @@ import (
type SiteInfo struct {
Multisite int
Siteurl string
Disabled int
}
type Site struct {
......@@ -139,6 +140,14 @@ func getSites() ([]Site, error) {
return make([]Site, 0), err
}
if now := time.Now(); siteInfo.Disabled == 1 {
logger.Println("Cron execution disabled indefinitely, listing no sites")
return make([]Site, 0), err
} else if siteInfo.Disabled > int(now.Unix()) {
logger.Printf("Cron execution disabled until %s, listing no sites", time.Unix(int64(siteInfo.Disabled), 0))
return make([]Site, 0), err
}
if siteInfo.Multisite == 1 {
sites, err := getMultisiteSites()
if err != nil {
......
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