- Updates cron API URL
- Removes cron daemon counter - Generates/saves cron daemon token as soon as its executed
This commit is contained in:
@ -50,10 +50,7 @@ class CronHelper {
|
|||||||
'timeout' => $timeout,
|
'timeout' => $timeout,
|
||||||
'user-agent' => 'MailPoet (www.mailpoet.com) Cron'
|
'user-agent' => 'MailPoet (www.mailpoet.com) Cron'
|
||||||
);
|
);
|
||||||
$result = wp_remote_get(
|
$result = wp_remote_get($url, $args);
|
||||||
self::getSiteUrl() . $url,
|
|
||||||
$args
|
|
||||||
);
|
|
||||||
return wp_remote_retrieve_body($result);
|
return wp_remote_retrieve_body($result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -39,6 +39,8 @@ class Daemon {
|
|||||||
) {
|
) {
|
||||||
$this->abortWithError(__('Invalid or missing token.'));
|
$this->abortWithError(__('Invalid or missing token.'));
|
||||||
}
|
}
|
||||||
|
$daemon['token'] = $this->token;
|
||||||
|
CronHelper::saveDaemon($daemon);
|
||||||
$this->abortIfStopped($daemon);
|
$this->abortIfStopped($daemon);
|
||||||
try {
|
try {
|
||||||
$scheduler = new SchedulerWorker($this->timer);
|
$scheduler = new SchedulerWorker($this->timer);
|
||||||
@ -55,15 +57,13 @@ class Daemon {
|
|||||||
// after each execution, re-read daemon data in case its status was changed
|
// after each execution, re-read daemon data in case its status was changed
|
||||||
// its status has changed
|
// its status has changed
|
||||||
$daemon = CronHelper::getDaemon();
|
$daemon = CronHelper::getDaemon();
|
||||||
if(!$daemon || $daemon['token'] !== $this->data['token']) {
|
if(!$daemon || $daemon['token'] !== $this->token) {
|
||||||
$this->terminateRequest();
|
$this->terminateRequest();
|
||||||
}
|
}
|
||||||
$daemon['counter']++;
|
|
||||||
$this->abortIfStopped($daemon);
|
$this->abortIfStopped($daemon);
|
||||||
if($daemon['status'] === self::STATUS_STARTING) {
|
if($daemon['status'] === self::STATUS_STARTING) {
|
||||||
$daemon['status'] = self::STATUS_STARTED;
|
$daemon['status'] = self::STATUS_STARTED;
|
||||||
}
|
}
|
||||||
$daemon['token'] = $this->token;
|
|
||||||
CronHelper::saveDaemon($daemon);
|
CronHelper::saveDaemon($daemon);
|
||||||
$this->callSelf();
|
$this->callSelf();
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user