diff --git a/config/packages/zenstruck_schedule.yaml b/config/packages/zenstruck_schedule.yaml index 19ef793..3cbde21 100644 --- a/config/packages/zenstruck_schedule.yaml +++ b/config/packages/zenstruck_schedule.yaml @@ -15,8 +15,8 @@ zenstruck_schedule: - task: app:bpn:xml-sync frequency: '*/15 8-19 * * *' - description: 'Sync BusPro XML data' + description: 'Sync BusPro XML data every 15 min. during peak hours' - task: app:bpn:xml-sync frequency: '0 20-23,0-7 * * *' - description: 'Sync BusPro XML data' + description: 'Sync BusPro XML data hourly outside peak hours' diff --git a/src/Command/BpnXmlSyncCommand.php b/src/Command/BpnXmlSyncCommand.php index 5e5d61b..d4cd5bf 100644 --- a/src/Command/BpnXmlSyncCommand.php +++ b/src/Command/BpnXmlSyncCommand.php @@ -63,13 +63,12 @@ class BpnXmlSyncCommand extends Command $force = $input->getOption('force'); $dryRun = $input->getOption('dry-run'); - try { - $remoteInfo = $this->readRemoteInfo(); - } catch (FilesystemException|\InvalidArgumentException $e) { - $io->error(sprintf('Failed to read remote info: %s', $e->getMessage())); - $this->logger->error('XML sync failed: could not read remote info', ['exception' => $e]); + $remoteInfo = $this->readRemoteInfo(); - return Command::FAILURE; + if (null === $remoteInfo) { + $io->warning('Remote info unavailable - will retry on next scheduled run'); + + return Command::SUCCESS; } $io->text(sprintf( @@ -127,11 +126,19 @@ class BpnXmlSyncCommand extends Command return Command::SUCCESS; } - private function readRemoteInfo(): XmlExportInfo + private function readRemoteInfo(): ?XmlExportInfo { - $content = $this->xmlSource->read(XmlExportInfo::getFilename()); + try { + $content = $this->xmlSource->read(XmlExportInfo::getFilename()); - return XmlExportInfo::fromString($content); + return XmlExportInfo::fromString($content); + } catch (FilesystemException|\InvalidArgumentException $e) { + $this->logger->warning('Could not read remote info file, likely being updated', [ + 'exception' => $e->getMessage(), + ]); + + return null; + } } private function readLocalInfo(): ?XmlExportInfo