Execute each cron worker in independent try/catch block

[MAILPOET-2017]
This commit is contained in:
Jan Jakeš
2019-04-30 12:15:31 +02:00
committed by M. Shull
parent feb374746b
commit b47b5de958

View File

@ -20,74 +20,32 @@ class Daemon {
function run($settings_daemon_data) { function run($settings_daemon_data) {
$settings_daemon_data['run_started_at'] = time(); $settings_daemon_data['run_started_at'] = time();
CronHelper::saveDaemon($settings_daemon_data); CronHelper::saveDaemon($settings_daemon_data);
foreach ($this->getWorkers() as $worker) {
try { try {
$this->executeMigrationWorker(); $worker->process();
$this->executeStatsNotificationsWorker();
$this->executeScheduleWorker();
$this->executeQueueWorker();
$this->executeSendingServiceKeyCheckWorker();
$this->executePremiumKeyCheckWorker();
$this->executeBounceWorker();
$this->executeExportFilesCleanupWorker();
$this->executeInactiveSubscribersWorker();
$settings = new SettingsController();
if ($settings->get('woo_commerce_list_sync_enabled')) {
$this->executeWooCommerceSyncWorker();
}
} catch (\Exception $e) { } catch (\Exception $e) {
CronHelper::saveDaemonLastError($e->getMessage()); CronHelper::saveDaemonLastError($e->getMessage());
} }
}
// Log successful execution // Log successful execution
CronHelper::saveDaemonRunCompleted(time()); CronHelper::saveDaemonRunCompleted(time());
} }
function executeScheduleWorker() { private function getWorkers() {
$scheduler = $this->workers_factory->createScheduleWorker($this->timer); yield $this->workers_factory->createMigrationWorker($this->timer);
return $scheduler->process(); yield $this->workers_factory->createStatsNotificationsWorker($this->timer);
} yield $this->workers_factory->createScheduleWorker($this->timer);
yield $this->workers_factory->createQueueWorker($this->timer);
function executeQueueWorker() { yield $this->workers_factory->createSendingServiceKeyCheckWorker($this->timer);
$queue = $this->workers_factory->createQueueWorker($this->timer); yield $this->workers_factory->createPremiumKeyCheckWorker($this->timer);
return $queue->process(); yield $this->workers_factory->createBounceWorker($this->timer);
} yield $this->workers_factory->createExportFilesCleanupWorker($this->timer);
yield $this->workers_factory->createInactiveSubscribersWorker($this->timer);
function executeStatsNotificationsWorker() { $settings = new SettingsController();
$worker = $this->workers_factory->createStatsNotificationsWorker($this->timer); if ($settings->get('woo_commerce_list_sync_enabled')) {
return $worker->process(); yield $this->workers_factory->createWooCommerceSyncWorker($this->timer);
} }
function executeSendingServiceKeyCheckWorker() {
$worker = $this->workers_factory->createSendingServiceKeyCheckWorker($this->timer);
return $worker->process();
}
function executePremiumKeyCheckWorker() {
$worker = $this->workers_factory->createPremiumKeyCheckWorker($this->timer);
return $worker->process();
}
function executeBounceWorker() {
$bounce = $this->workers_factory->createBounceWorker($this->timer);
return $bounce->process();
}
function executeWooCommerceSyncWorker() {
$worker = $this->workers_factory->createWooCommerceSyncWorker($this->timer);
return $worker->process();
}
function executeMigrationWorker() {
$migration = $this->workers_factory->createMigrationWorker($this->timer);
return $migration->process();
}
function executeExportFilesCleanupWorker() {
$worker = $this->workers_factory->createExportFilesCleanupWorker($this->timer);
return $worker->process();
}
function executeInactiveSubscribersWorker() {
$worker = $this->workers_factory->createInactiveSubscribersWorker($this->timer);
return $worker->process();
} }
} }