*fix - status on vs off, not bool

pull/844/head
Ing. Petr Suchy 2020-01-30 15:36:00 +01:00
parent 6f2c5f49ca
commit b668a0b842
No known key found for this signature in database
GPG Key ID: 5BC9AFE53BB0E8A2
1 changed files with 14 additions and 9 deletions

View File

@ -28,6 +28,9 @@
namespace { namespace {
// include main configuration and functionality // include main configuration and functionality
use psm\Router;
use psm\Util\Server\UpdateManager;
require_once __DIR__ . '/../src/bootstrap.php'; require_once __DIR__ . '/../src/bootstrap.php';
if (!psm_is_cli()) { if (!psm_is_cli()) {
@ -82,7 +85,7 @@ namespace {
// if you want to change PSM_CRON_TIMEOUT, have a look in src/includes/psmconfig.inc.php. // if you want to change PSM_CRON_TIMEOUT, have a look in src/includes/psmconfig.inc.php.
// or you can provide the --timeout=x argument // or you can provide the --timeout=x argument
$status = 'on'; $status = null;
if (PHP_SAPI === 'cli') { if (PHP_SAPI === 'cli') {
$shortOptions = 's:'; // status $shortOptions = 's:'; // status
@ -108,10 +111,10 @@ namespace {
} }
} }
if ($status === 'on') { if ($status === 'off') {
$confPrefix = 'cron_';
} else {
$confPrefix = 'cron_off_'; $confPrefix = 'cron_off_';
} else {
$confPrefix = 'cron_';
} }
$time = time(); $time = time();
@ -127,10 +130,12 @@ namespace {
} }
psm_update_conf($confPrefix . 'running_time', $time); psm_update_conf($confPrefix . 'running_time', $time);
/** @var Router $router */
/** @var UpdateManager $autorun */
$autorun = $router->getService('util.server.updatemanager'); $autorun = $router->getService('util.server.updatemanager');
if ($status === 'on') { if ($status !== 'off') {
$autorun->run(true, false); $autorun->run(true, $status);
} else { } else {
set_time_limit(60); set_time_limit(60);
if (false === defined('CRON_DOWN_INTERVAL')) { if (false === defined('CRON_DOWN_INTERVAL')) {
@ -139,7 +144,7 @@ namespace {
$start = time(); $start = time();
$i = 0; $i = 0;
while ($i < 59) { while ($i < 59) {
$autorun->run(true, true); $autorun->run(true, $status);
if ($i < (59 - CRON_DOWN_INTERVAL)) { if ($i < (59 - CRON_DOWN_INTERVAL)) {
time_sleep_until($start + $i + CRON_DOWN_INTERVAL); time_sleep_until($start + $i + CRON_DOWN_INTERVAL);
} }