From ca4150e1da0745ae466280096c6a1aef7c58be0d Mon Sep 17 00:00:00 2001 From: Syndesi Date: Wed, 23 Aug 2023 08:51:05 +0200 Subject: [PATCH 1/9] Improve documentation. --- CHANGELOG.md | 2 + docs/_sidebar.md | 3 + docs/development/best-practices.md | 65 +++++++++++++++++++ docs/development/long-term-plans.md | 24 +++++++ docs/getting-started/hardware-requirements.md | 44 +++++++++++++ 5 files changed, 138 insertions(+) create mode 100644 docs/development/best-practices.md create mode 100644 docs/development/long-term-plans.md diff --git a/CHANGELOG.md b/CHANGELOG.md index a980a868..642a6ed7 100755 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## Unreleased ### Added - Add CI workflow to check for upstream Alpine updated. +### Changed +- Improve documentation. ## 0.0.24 - 2023-08-21 ### Changed diff --git a/docs/_sidebar.md b/docs/_sidebar.md index 6aa07e73..6a448fcb 100755 --- a/docs/_sidebar.md +++ b/docs/_sidebar.md @@ -36,3 +36,6 @@ - Commands - [Backup Commands](/commands/backup) - [Database Commands](/commands/database) +- Development + - [Best Practices](/development/best-practices) + - [Long Term Plans](/development/long-term-plans) diff --git a/docs/development/best-practices.md b/docs/development/best-practices.md new file mode 100644 index 00000000..28652b86 --- /dev/null +++ b/docs/development/best-practices.md @@ -0,0 +1,65 @@ +# Best Practices + +As Ember Nexus internally uses Symfony, it also uses +[Symfony's best practices](https://symfony.com/doc/current/best_practices.html). + +## Language + +The source code of Ember Nexus and responses generated by Ember Nexus API should be only written in **English**. + +There are two reasons for it: + +- Search engines more easily find exceptions returned in a single language, helping with debugging and general + usability. +- As English is the Lingua Franca of the IT industry, it should be the primary language used in this project. + +Documentations and general user guides should always be available in English, and additional translations or regional +adaptations can be created. +It should be noted that Ember Nexus strives towards long-term stability; i.e., it is better not to support language X +than to shortly abandon language X after trial usage. + +When deciding between using the active vs. passive voice, asking the following question helps: + +> Is it an advantage for the reader to know the performer of the action? + +If the answer is Yes, use active voice. If the answer is No, use passive voice. + +See [Technical Writing: Active vs. Passive voice](https://medium.com/@DaphneWatson/technical-writing-active-vs-passive-voice-485dfaa4e498) +for details. + +## Coding Style + +Ember Nexus API tries to implement object-orientated code with patterns where it makes sense. Duplicate code should be +reduced if the code's complexity is similar. +Using easily readable code is better than using the least amount of lines +or highly optimized code. + +Refactoring parts of the source code is always possible as long as code changes are covered by unit tests and existing +feature tests are passed. + +Try to keep the line length below 120 chars. + +## Logging and Exceptions + +Both log messages and exceptions should adhere to a few key principles: + +- Messages should provide context why they are created. +- Messages should provide one specific reason, ideally a unique property or identifier. +- Messages should not contain sensitive data like passwords, hashes, and tokens. + +Log messages should be created in the following scenarios: + +- Important events in the lifetime of the API should be documented. This includes startup, shutdown, and backups. +- Security events like creating or updating users, tokens, and sessions should always be logged. If possible, use the + user's unique identifier for context. +- Administrative actions should be fully logged: + - Interactions with the command line. + - Interactions with the API through users with administrative access. + +Exceptions should be created in the following instances: + +- If input validation returns an error. +- If an action is forbidden, likely due to missing security privileges. +- If the requested data does not exist. +- If there is a logic conflict. +- In other problematic instances. diff --git a/docs/development/long-term-plans.md b/docs/development/long-term-plans.md new file mode 100644 index 00000000..fe098ae6 --- /dev/null +++ b/docs/development/long-term-plans.md @@ -0,0 +1,24 @@ +# Long-Term Plans + +The Ember Nexus API is not intended to be modified or extended by third parties directly - we do not guarantee that +internal code is not refactored or creates breaking changes in minor version updates. + +If you need to handle custom business logic or general automation, then it is recommended to create a separate +web app, which communicates with Ember Nexus over its API, which is stable and will not have breaking changes in minor +version updates. + +## Version 2 of Ember Nexus API + +While no guarantees can be given, we want to experiment if rewriting Ember Nexus API in Rust provides significant +performance benefits. +This experiment starts after the release of version 1.0.0 and will be covered in separate blog +posts. + +The API endpoints of version 2.0, regardless if the API uses Rust or not, will likely be highly similar. + +## Native Support for HTTP 2 / HTTP 3 + +Neither HTTP 2 nor HTTP 3 will be supported during version 1.x. It is recommended to use a reverse proxy like +[Traefik](https://traefik.io/traefik/). + +Support for version 2.x is likely. diff --git a/docs/getting-started/hardware-requirements.md b/docs/getting-started/hardware-requirements.md index 8c093e2e..45ed5aa8 100755 --- a/docs/getting-started/hardware-requirements.md +++ b/docs/getting-started/hardware-requirements.md @@ -1,5 +1,49 @@ # Hardware Requirements +Computer Architectures + +The Ember Nexus API stack currently supports the following CPU architectures: + +| Software | amd64 | arm64 | riscv64 | ppc64le | s390x | mips64le | +| --------------- | ----- | ----- | ------- | ------- | ----- | -------- | +| **Ember Nexus API** | ✅ 1 | ✅ 2 | 🚧 3 | ⛔ 4 | ⛔ 4 | ⛔ 4 | +| Neo4j | ✅ 5 | ✅ 5 | 🚧 6 | 🚧 6 | 🚧 6 | ⛔ 7 | +| MongoDB | ✅ 8 | ✅ 8 | ⛔ 7 | ✅ 9 | ✅ 9 | ⛔ 7 | +| Elasticsearch | ✅ 10 | ✅ 10 | 🚧 6 | 🚧 6 | 🚧 6 | ⛔ 7 | +| Redis | ✅ 11 | ✅ 11 | 🚧 12 | ✅ 11 | ✅ 11 | ✅ 11 | +| RabbitMQ | ✅ 13 | ✅ 13 | ⛔ 14 | ✅ 13 | ✅ 13 | ⛔ 7 | +| MinIO | ✅ 15 | ✅ 15 | ⛔ 16 | ✅ 15 | ✅ 15 | ✅ 17 | + +1: The architecture amd64 is supported by default. +2: The architecture arm64 is supported since 0.0.23. +3: The architecture riscv64 will likely be supported once a) computers and CI/CD infrastructure get more available and +b) upstream dependencies get official support; see also [PHP](https://github.com/docker-library/php/issues/1279) and +[NGINX Unit](https://github.com/nginx/unit/issues/926). +4: No support is planned, although you can ask for it by opening a [GitHub issue](https://github.com/ember-nexus/api/issues). +It likely requires hardware donation or general collaboration. +5: Neo4j [officially supports](https://neo4j.com/docs/operations-manual/current/installation/requirements/) +amd64 and arm64. +6: No official support, although Java applications should be able to run on these architectures. +7: Software is not runnable on this architecture. +8: MongoDB [officially supports](https://www.mongodb.com/docs/manual/installation/#supported-platforms) amd64 and arm64 +in their community and enterprise versions. +9: MongoDB supports these architectures in +[enterprise-only versions](https://www.mongodb.com/docs/manual/installation/#supported-platforms). +10: Elasticsearch [officially supports](https://www.elastic.co/support/matrix) amd64 and arm64. +11: Redis [supports most architectures](https://hub.docker.com/_/redis). +12: Redis seems to be [experimentally runable](https://github.com/redis/redis/pull/12349) on RISC V. +13: RabbitMQ supports [most platforms Erlang covers](https://www.rabbitmq.com/platforms.html). +14: RabbitMQ [might support](https://www.rabbitmq.com/platforms.html) RISC V once it is +[supported by Erlang](https://github.com/erlang/otp/issues/7498). +15: MinIO [supports](https://min.io/docs/minio/linux/operations/install-deploy-manage/deploy-minio-single-node-multi-drive.html#download-the-minio-server) +amd64, arm64, ppc64le as well as s390x. +16: MinIO [does not support](https://github.com/minio/minio/pull/17161) RISC V yet, although there is some community +work done. +17: MinIO [seems to support](https://github.com/minio/minio/blob/adb8be069ee18f5360c2a9dcd22054b113493fec/buildscripts/cross-compile.sh#L12C34-L12C44) +mips64, although it is not available through Docker. + +If this information needs to be corrected, please open a [GitHub issue](https://github.com/ember-nexus/api/issues). + ## Local and Development Setups For local and development purposes, the whole stack can be hosted on a single machine with at least 8 GB of RAM, From 7a43ce4f2f73cb93d344398ffbd24c6387c33136 Mon Sep 17 00:00:00 2001 From: Syndesi Date: Fri, 25 Aug 2023 22:04:40 +0200 Subject: [PATCH 2/9] WIP rework exception and logging. --- docs/development/exceptions.md | 0 .../CheckUserSuppliedPropertiesEvent.php | 36 --------- ...eckUserSuppliedPropertiesEventListener.php | 17 ---- ...eckUserSuppliedPropertiesEventListener.php | 16 ---- ...eckUserSuppliedPropertiesEventListener.php | 17 ---- ...eckUserSuppliedPropertiesEventListener.php | 16 ---- src/Command/BackupCreateCommand.php | 13 ++-- src/Command/BackupFetchCommand.php | 11 +-- src/Command/BackupLoadCommand.php | 13 ++-- .../Element/DeleteElementController.php | 14 ++-- .../Element/GetChildrenController.php | 14 ++-- .../Element/GetElementController.php | 12 +-- src/Controller/Element/GetIndexController.php | 7 +- .../Element/GetParentsController.php | 14 ++-- .../Element/GetRelatedController.php | 14 ++-- .../Element/PatchElementController.php | 14 ++-- .../Element/PostElementController.php | 30 ++++---- .../Element/PostIndexController.php | 44 ++++++++--- .../Element/PutElementController.php | 12 +-- .../Error/ExceptionDetailController.php | 51 ++++++++++++ .../Error/assets/ember-nexus-api-logo.txt | 7 ++ .../Error/assets/error-400-bad-content.txt | 6 ++ .../assets/error-400-forbidden-property.txt | 7 ++ ...error-400-incomplete-mutual-dependency.txt | 7 ++ .../assets/error-400-missing-property.txt | 6 ++ .../File/DeleteElementFileController.php | 9 ++- .../File/GetElementFileController.php | 9 ++- .../File/PatchElementFileController.php | 9 ++- .../File/PostElementFileController.php | 9 ++- .../File/PutElementFileController.php | 9 ++- .../Problem/ClientBadRequestController.php | 24 ------ .../Problem/ClientForbiddenController.php | 24 ------ .../Problem/ClientNotFoundController.php | 24 ------ .../ClientTooManyRequestsController.php | 24 ------ .../Problem/ClientUnauthorizedController.php | 24 ------ .../Search/PostSearchController.php | 23 +++--- .../GetInstanceConfigurationController.php | 7 +- .../User/PostRegisterController.php | 18 +++-- src/Controller/User/PostTokenController.php | 7 +- .../WebDAV/CopyElementController.php | 9 ++- .../WebDAV/LockElementController.php | 9 ++- .../WebDAV/MkcolElementController.php | 9 ++- .../WebDAV/MoveElementController.php | 9 ++- .../WebDAV/PropfindElementController.php | 9 ++- .../WebDAV/ProppatchElementController.php | 9 ++- .../WebDAV/UnlockElementController.php | 9 ++- ...ationElementDefragmentizeEventListener.php | 11 +-- ...ropertyElementFragmentizeEventListener.php | 6 +- ...ropertyElementFragmentizeEventListener.php | 6 +- .../NodeElementFragmentizeEventListener.php | 5 +- ...elationElementFragmentizeEventListener.php | 9 ++- ...ropertyElementFragmentizeEventListener.php | 6 +- ...atedElementPropertyChangeEventListener.php | 3 +- .../IdElementPropertyChangeEventListener.php | 3 +- ...okenElementPropertyChangeEventListener.php | 5 +- ...atedElementPropertyChangeEventListener.php | 3 +- ...UserElementPropertyChangeEventListener.php | 5 +- .../CreatedElementPreWriteEventListener.php | 3 +- .../OwnershipChangeEventListener.php | 3 +- .../UpdatedElementPreWriteEventListener.php | 3 +- .../EventListener/ExceptionEventListener.php | 17 ++-- ...NormalizedValueToRawValueEventListener.php | 6 +- ...RawValueToNormalizedValueEventListener.php | 3 +- ...piKeyCheckOnKernelRequestEventListener.php | 12 +-- ...n.php => Client400BadContentException.php} | 8 +- .../Client400ForbiddenPropertyException.php | 19 +++++ ...400IncompleteMutualDependencyException.php | 19 +++++ .../Client400MissingPropertyException.php | 19 +++++ .../Client400ReservedIdentifierException.php | 19 +++++ .../Client401UnauthorizedException.php | 19 +++++ src/Exception/Client403ForbiddenException.php | 19 +++++ src/Exception/Client404NotFoundException.php | 19 +++++ .../Client405MethodNotAllowedException.php | 19 +++++ .../Client429TooManyRequestsException.php | 19 +++++ src/Exception/ClientBadIdException.php | 17 ---- src/Exception/ClientBadRequestException.php | 17 ---- src/Exception/ClientForbiddenException.php | 17 ---- src/Exception/ClientNotFoundException.php | 17 ---- .../ClientTooManyRequestsException.php | 17 ---- src/Exception/ClientUnauthorizedException.php | 17 ---- src/Exception/NotImplementedException.php | 17 ---- ...Exception.php => ProblemJsonException.php} | 16 ++-- .../Server500InternalServerErrorException.php | 19 +++++ ...n.php => Server500LogicErrorException.php} | 10 ++- .../Server501NotImplementedException.php | 19 +++++ .../Server503ServiceUnavailableException.php | 19 +++++ .../Client400BadContentExceptionFactory.php | 37 +++++++++ ...nt400ForbiddenPropertyExceptionFactory.php | 35 +++++++++ ...mpleteMutualDependencyExceptionFactory.php | 77 +++++++++++++++++++ ...ient400MissingPropertyExceptionFactory.php | 36 +++++++++ ...t400ReservedIdentifierExceptionFactory.php | 35 +++++++++ .../Client401UnauthorizedExceptionFactory.php | 28 +++++++ .../Client403ForbiddenExceptionFactory.php | 28 +++++++ .../Client404NotFoundExceptionFactory.php | 28 +++++++ ...ent405MethodNotAllowedExceptionFactory.php | 28 +++++++ ...ient429TooManyRequestsExceptionFactory.php | 28 +++++++ ...500InternalServerErrorExceptionFactory.php | 39 ++++++++++ .../Server500LogicExceptionFactory.php | 39 ++++++++++ ...erver501NotImplementedExceptionFactory.php | 28 +++++++ ...r503ServiceUnavailableExceptionFactory.php | 42 ++++++++++ src/Factory/RabbitMQFactory.php | 3 +- src/Response/TextResponse.php | 24 ++++++ src/Security/AuthProvider.php | 3 +- src/Security/TokenGenerator.php | 3 +- src/Service/CollectionService.php | 7 +- src/Service/ElementManager.php | 8 +- src/Service/ElementResponseService.php | 3 +- src/Service/RawToElementService.php | 5 +- src/Style/EmberNexusStyle.php | 3 +- 109 files changed, 1197 insertions(+), 541 deletions(-) create mode 100644 docs/development/exceptions.md delete mode 100644 refactor/_userSuppliedProperties/Event/CheckUserSuppliedPropertiesEvent.php delete mode 100644 refactor/_userSuppliedProperties/EventListener/EndCheckUserSuppliedPropertiesEventListener.php delete mode 100644 refactor/_userSuppliedProperties/EventListener/IdCheckUserSuppliedPropertiesEventListener.php delete mode 100644 refactor/_userSuppliedProperties/EventListener/StartCheckUserSuppliedPropertiesEventListener.php delete mode 100644 refactor/_userSuppliedProperties/EventListener/TypeCheckUserSuppliedPropertiesEventListener.php create mode 100644 src/Controller/Error/ExceptionDetailController.php create mode 100644 src/Controller/Error/assets/ember-nexus-api-logo.txt create mode 100644 src/Controller/Error/assets/error-400-bad-content.txt create mode 100644 src/Controller/Error/assets/error-400-forbidden-property.txt create mode 100644 src/Controller/Error/assets/error-400-incomplete-mutual-dependency.txt create mode 100644 src/Controller/Error/assets/error-400-missing-property.txt delete mode 100755 src/Controller/Problem/ClientBadRequestController.php delete mode 100755 src/Controller/Problem/ClientForbiddenController.php delete mode 100755 src/Controller/Problem/ClientNotFoundController.php delete mode 100755 src/Controller/Problem/ClientTooManyRequestsController.php delete mode 100755 src/Controller/Problem/ClientUnauthorizedController.php rename src/Exception/{ClientException.php => Client400BadContentException.php} (64%) mode change 100755 => 100644 create mode 100644 src/Exception/Client400ForbiddenPropertyException.php create mode 100644 src/Exception/Client400IncompleteMutualDependencyException.php create mode 100644 src/Exception/Client400MissingPropertyException.php create mode 100644 src/Exception/Client400ReservedIdentifierException.php create mode 100644 src/Exception/Client401UnauthorizedException.php create mode 100644 src/Exception/Client403ForbiddenException.php create mode 100644 src/Exception/Client404NotFoundException.php create mode 100644 src/Exception/Client405MethodNotAllowedException.php create mode 100644 src/Exception/Client429TooManyRequestsException.php delete mode 100644 src/Exception/ClientBadIdException.php delete mode 100755 src/Exception/ClientBadRequestException.php delete mode 100755 src/Exception/ClientForbiddenException.php delete mode 100755 src/Exception/ClientNotFoundException.php delete mode 100755 src/Exception/ClientTooManyRequestsException.php delete mode 100755 src/Exception/ClientUnauthorizedException.php delete mode 100644 src/Exception/NotImplementedException.php rename src/Exception/{ExtendedException.php => ProblemJsonException.php} (62%) mode change 100755 => 100644 create mode 100644 src/Exception/Server500InternalServerErrorException.php rename src/Exception/{ServerException.php => Server500LogicErrorException.php} (58%) mode change 100755 => 100644 create mode 100644 src/Exception/Server501NotImplementedException.php create mode 100644 src/Exception/Server503ServiceUnavailableException.php create mode 100644 src/Factory/Exception/Client400BadContentExceptionFactory.php create mode 100644 src/Factory/Exception/Client400ForbiddenPropertyExceptionFactory.php create mode 100644 src/Factory/Exception/Client400IncompleteMutualDependencyExceptionFactory.php create mode 100644 src/Factory/Exception/Client400MissingPropertyExceptionFactory.php create mode 100644 src/Factory/Exception/Client400ReservedIdentifierExceptionFactory.php create mode 100644 src/Factory/Exception/Client401UnauthorizedExceptionFactory.php create mode 100644 src/Factory/Exception/Client403ForbiddenExceptionFactory.php create mode 100644 src/Factory/Exception/Client404NotFoundExceptionFactory.php create mode 100644 src/Factory/Exception/Client405MethodNotAllowedExceptionFactory.php create mode 100644 src/Factory/Exception/Client429TooManyRequestsExceptionFactory.php create mode 100644 src/Factory/Exception/Server500InternalServerErrorExceptionFactory.php create mode 100644 src/Factory/Exception/Server500LogicExceptionFactory.php create mode 100644 src/Factory/Exception/Server501NotImplementedExceptionFactory.php create mode 100644 src/Factory/Exception/Server503ServiceUnavailableExceptionFactory.php create mode 100644 src/Response/TextResponse.php diff --git a/docs/development/exceptions.md b/docs/development/exceptions.md new file mode 100644 index 00000000..e69de29b diff --git a/refactor/_userSuppliedProperties/Event/CheckUserSuppliedPropertiesEvent.php b/refactor/_userSuppliedProperties/Event/CheckUserSuppliedPropertiesEvent.php deleted file mode 100644 index 028ba95d..00000000 --- a/refactor/_userSuppliedProperties/Event/CheckUserSuppliedPropertiesEvent.php +++ /dev/null @@ -1,36 +0,0 @@ - $newProperties - */ - public function __construct( - private NodeElementInterface|RelationElementInterface $element, - array $newProperties - ) { - $this->addProperties($newProperties); - } - - public function getElement(): RelationElementInterface|NodeElementInterface - { - return $this->element; - } - - public function setElement(RelationElementInterface|NodeElementInterface $element): void - { - $this->element = $element; - } -} diff --git a/refactor/_userSuppliedProperties/EventListener/EndCheckUserSuppliedPropertiesEventListener.php b/refactor/_userSuppliedProperties/EventListener/EndCheckUserSuppliedPropertiesEventListener.php deleted file mode 100644 index de26eadb..00000000 --- a/refactor/_userSuppliedProperties/EventListener/EndCheckUserSuppliedPropertiesEventListener.php +++ /dev/null @@ -1,17 +0,0 @@ -getElement() instanceof RelationElement && $event->hasProperty('end')) { - throw new ClientBadRequestException(detail: 'Manually setting the end property is forbidden.'); - } - } -} diff --git a/refactor/_userSuppliedProperties/EventListener/IdCheckUserSuppliedPropertiesEventListener.php b/refactor/_userSuppliedProperties/EventListener/IdCheckUserSuppliedPropertiesEventListener.php deleted file mode 100644 index 7dbf54b2..00000000 --- a/refactor/_userSuppliedProperties/EventListener/IdCheckUserSuppliedPropertiesEventListener.php +++ /dev/null @@ -1,16 +0,0 @@ -getElement()->getIdentifier() && $event->hasProperty('id')) { - throw new ClientBadRequestException(detail: 'Manually changing the id property is forbidden.'); - } - } -} diff --git a/refactor/_userSuppliedProperties/EventListener/StartCheckUserSuppliedPropertiesEventListener.php b/refactor/_userSuppliedProperties/EventListener/StartCheckUserSuppliedPropertiesEventListener.php deleted file mode 100644 index 7922eeaa..00000000 --- a/refactor/_userSuppliedProperties/EventListener/StartCheckUserSuppliedPropertiesEventListener.php +++ /dev/null @@ -1,17 +0,0 @@ -getElement() instanceof RelationElement && $event->hasProperty('start')) { - throw new ClientBadRequestException(detail: 'Manually setting the start property is forbidden.'); - } - } -} diff --git a/refactor/_userSuppliedProperties/EventListener/TypeCheckUserSuppliedPropertiesEventListener.php b/refactor/_userSuppliedProperties/EventListener/TypeCheckUserSuppliedPropertiesEventListener.php deleted file mode 100644 index 9b05eb3c..00000000 --- a/refactor/_userSuppliedProperties/EventListener/TypeCheckUserSuppliedPropertiesEventListener.php +++ /dev/null @@ -1,16 +0,0 @@ -hasProperty('type')) { - throw new ClientBadRequestException(detail: 'Manually setting the type property is forbidden.'); - } - } -} diff --git a/src/Command/BackupCreateCommand.php b/src/Command/BackupCreateCommand.php index b62ddcd8..26aba476 100755 --- a/src/Command/BackupCreateCommand.php +++ b/src/Command/BackupCreateCommand.php @@ -5,6 +5,7 @@ use App\Service\ElementManager; use App\Service\ElementToRawService; use App\Style\EmberNexusStyle; +use Exception; use Laudis\Neo4j\Databags\Statement; use League\Flysystem\FilesystemOperator; use LogicException; @@ -78,7 +79,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int $this->prettyPrint = $input->getOption('pretty'); $this->ndjson = $input->getOption('ndjson'); if ($this->prettyPrint && $this->ndjson) { - throw new \Exception('Pretty print and ndjson are mutually exclusive.'); + throw new Exception('Pretty print and ndjson are mutually exclusive.'); } $this->io->title('Backup Create'); $this->createBackupFolders(); @@ -144,7 +145,7 @@ private function backupNodes(): void foreach ($nodeIds as $nodeId) { $node = $this->elementManager->getNode($nodeId); if (null === $node) { - throw new \LogicException('Node can not be null'); + throw new LogicException('Node can not be null'); } $data = $this->elementToRawService->elementToRaw($node); $json = \Safe\json_encode($data, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE | ($this->prettyPrint ? JSON_PRETTY_PRINT : 0)); @@ -195,7 +196,7 @@ private function backupRelations(): void foreach ($relationIds as $relationId) { $relation = $this->elementManager->getRelation($relationId); if (null === $relation) { - throw new \LogicException('Relation can not be null'); + throw new LogicException('Relation can not be null'); } $data = $this->elementToRawService->elementToRaw($relation); $json = \Safe\json_encode($data, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE | ($this->prettyPrint ? JSON_PRETTY_PRINT : 0)); @@ -263,15 +264,15 @@ private function checkBackupName(string $backupName): string $backupName = trim($backupName); if ('' === $backupName) { - throw new \LogicException("Backup name can not be ''"); + throw new LogicException("Backup name can not be ''"); } if ('.' === $backupName) { - throw new \LogicException("Backup name can not be '.'"); + throw new LogicException("Backup name can not be '.'"); } if ('..' === $backupName) { - throw new \LogicException("Backup name can not be '..'"); + throw new LogicException("Backup name can not be '..'"); } // todo remove comment block diff --git a/src/Command/BackupFetchCommand.php b/src/Command/BackupFetchCommand.php index 5222b7da..97b5e2f1 100644 --- a/src/Command/BackupFetchCommand.php +++ b/src/Command/BackupFetchCommand.php @@ -3,6 +3,7 @@ namespace App\Command; use App\Style\EmberNexusStyle; +use Exception; use League\Flysystem\Filesystem; use League\Flysystem\FilesystemOperator; use League\Flysystem\MountManager; @@ -71,17 +72,17 @@ protected function execute(InputInterface $input, OutputInterface $output): int $backupName = $input->getArgument('name'); $backupLocation = $this->findBackupRootFolder($filesystem); if (null === $backupLocation) { - throw new \Exception('Unable to find the file summary.json in backup archive.'); + throw new Exception('Unable to find the file summary.json in backup archive.'); } $this->io->writeln(sprintf('Found backup inside ZIP in folder %s.', $backupLocation)); if (!$filesystem->directoryExists(sprintf('%s/node', $backupLocation))) { - throw new \Exception('ZIP archive does not contain required node folder.'); + throw new Exception('ZIP archive does not contain required node folder.'); } if (!$filesystem->directoryExists(sprintf('%s/relation', $backupLocation))) { - throw new \Exception('ZIP archive does not contain required relation folder.'); + throw new Exception('ZIP archive does not contain required relation folder.'); } if (!$filesystem->directoryExists(sprintf('%s/file', $backupLocation))) { - throw new \Exception('ZIP archive does not contain required file folder.'); + throw new Exception('ZIP archive does not contain required file folder.'); } $this->io->writeln('Required folders exist.'); $this->io->stopSection('Download complete.'); @@ -235,7 +236,7 @@ private function checkBackupNameIsAvailable(string $name, bool $force): void { if ($this->backupStorage->directoryExists($name)) { if (!$force) { - throw new \Exception(sprintf("Unable to fetch remote backup with name '%s', as another backup with the same name already exists. Delete it or use --force to overwrite existing backup.", $name)); + throw new Exception(sprintf("Unable to fetch remote backup with name '%s', as another backup with the same name already exists. Delete it or use --force to overwrite existing backup.", $name)); } $this->backupStorage->deleteDirectory($name); } diff --git a/src/Command/BackupLoadCommand.php b/src/Command/BackupLoadCommand.php index e0796bcb..8acf1ce4 100755 --- a/src/Command/BackupLoadCommand.php +++ b/src/Command/BackupLoadCommand.php @@ -11,6 +11,7 @@ use App\Type\AppStateType; use Laudis\Neo4j\Databags\Statement; use League\Flysystem\FilesystemOperator; +use LogicException; use Ramsey\Uuid\Rfc4122\UuidV4; use Symfony\Component\Console\Attribute\AsCommand; use Symfony\Component\Console\Command\Command; @@ -220,19 +221,19 @@ private function checkBackupName(string $backupName): string $backupName = trim($backupName); if ('' === $backupName) { - throw new \LogicException("Backup name can not be ''"); + throw new LogicException("Backup name can not be ''"); } if ('.' === $backupName) { - throw new \LogicException("Backup name can not be '.'"); + throw new LogicException("Backup name can not be '.'"); } if ('..' === $backupName) { - throw new \LogicException("Backup name can not be '..'"); + throw new LogicException("Backup name can not be '..'"); } if (!$this->backupStorage->directoryExists($backupName)) { - throw new \LogicException(sprintf("Backup with the name '%s' does not exist", $backupName)); + throw new LogicException(sprintf("Backup with the name '%s' does not exist", $backupName)); } return $backupName; @@ -241,7 +242,7 @@ private function checkBackupName(string $backupName): string private function loadSummary(): void { if (!$this->backupStorage->fileExists($this->backupName.'/summary.json')) { - throw new \LogicException(sprintf("Backup with the name '%s' does not contain a summary.json", $this->backupName)); + throw new LogicException(sprintf("Backup with the name '%s' does not contain a summary.json", $this->backupName)); } $data = \Safe\json_decode($this->backupStorage->read($this->backupName.'/summary.json'), true); $nodeCount = 0; @@ -270,7 +271,7 @@ private function checkDatabaseIsEmpty(): void Statement::create('MATCH ()-[r]->() RETURN count(r) as count') )->first()->get('count'); if ($nodeCount > 0 || $relationCount > 0) { - throw new \LogicException('Loading backups into non-empty databases is not supported'); + throw new LogicException('Loading backups into non-empty databases is not supported'); } } } diff --git a/src/Controller/Element/DeleteElementController.php b/src/Controller/Element/DeleteElementController.php index 7f6018c3..4663b46c 100644 --- a/src/Controller/Element/DeleteElementController.php +++ b/src/Controller/Element/DeleteElementController.php @@ -2,8 +2,8 @@ namespace App\Controller\Element; -use App\Exception\ClientNotFoundException; -use App\Exception\ClientUnauthorizedException; +use App\Factory\Exception\Client401UnauthorizedExceptionFactory; +use App\Factory\Exception\Client404NotFoundExceptionFactory; use App\Helper\Regex; use App\Response\NoContentResponse; use App\Security\AccessChecker; @@ -20,7 +20,9 @@ class DeleteElementController extends AbstractController public function __construct( private ElementManager $elementManager, private AuthProvider $authProvider, - private AccessChecker $accessChecker + private AccessChecker $accessChecker, + private Client401UnauthorizedExceptionFactory $client401UnauthorizedExceptionFactory, + private Client404NotFoundExceptionFactory $client404NotFoundExceptionFactory ) { } @@ -38,16 +40,16 @@ public function deleteElement(string $uuid): Response $userUuid = $this->authProvider->getUserUuid(); if (!$userUuid) { - throw new ClientUnauthorizedException(); + throw $this->client401UnauthorizedExceptionFactory->createFromTemplate(); } if (!$this->accessChecker->hasAccessToElement($userUuid, $elementUuid, AccessType::DELETE)) { - throw new ClientNotFoundException(); + throw $this->client404NotFoundExceptionFactory->createFromTemplate(); } $element = $this->elementManager->getElement($elementUuid); if (null === $element) { - throw new ClientNotFoundException(); + throw $this->client404NotFoundExceptionFactory->createFromTemplate(); } $this->elementManager->delete($element); $this->elementManager->flush(); diff --git a/src/Controller/Element/GetChildrenController.php b/src/Controller/Element/GetChildrenController.php index ef8aa906..064c22e9 100644 --- a/src/Controller/Element/GetChildrenController.php +++ b/src/Controller/Element/GetChildrenController.php @@ -2,8 +2,8 @@ namespace App\Controller\Element; -use App\Exception\ClientNotFoundException; -use App\Exception\ClientUnauthorizedException; +use App\Factory\Exception\Client401UnauthorizedExceptionFactory; +use App\Factory\Exception\Client404NotFoundExceptionFactory; use App\Helper\Regex; use App\Security\AccessChecker; use App\Security\AuthProvider; @@ -23,7 +23,9 @@ public function __construct( private CypherEntityManager $cypherEntityManager, private CollectionService $collectionService, private AuthProvider $authProvider, - private AccessChecker $accessChecker + private AccessChecker $accessChecker, + private Client401UnauthorizedExceptionFactory $client401UnauthorizedExceptionFactory, + private Client404NotFoundExceptionFactory $client404NotFoundExceptionFactory ) { } @@ -41,17 +43,17 @@ public function getChildren(string $uuid): Response $userUuid = $this->authProvider->getUserUuid(); if (!$userUuid) { - throw new ClientUnauthorizedException(); + throw $this->client401UnauthorizedExceptionFactory->createFromTemplate(); } $type = $this->accessChecker->getElementType($parentUuid); if (ElementType::RELATION === $type) { // relations can not be parent nodes - throw new ClientNotFoundException(); + throw $this->client404NotFoundExceptionFactory->createFromTemplate(); } if (!$this->accessChecker->hasAccessToElement($userUuid, $parentUuid, AccessType::READ)) { - throw new ClientNotFoundException(); + throw $this->client404NotFoundExceptionFactory->createFromTemplate(); } $cypherClient = $this->cypherEntityManager->getClient(); diff --git a/src/Controller/Element/GetElementController.php b/src/Controller/Element/GetElementController.php index 21867c03..8770aea6 100644 --- a/src/Controller/Element/GetElementController.php +++ b/src/Controller/Element/GetElementController.php @@ -2,8 +2,8 @@ namespace App\Controller\Element; -use App\Exception\ClientNotFoundException; -use App\Exception\ClientUnauthorizedException; +use App\Factory\Exception\Client401UnauthorizedExceptionFactory; +use App\Factory\Exception\Client404NotFoundExceptionFactory; use App\Helper\Regex; use App\Security\AccessChecker; use App\Security\AuthProvider; @@ -19,7 +19,9 @@ class GetElementController extends AbstractController public function __construct( private ElementResponseService $elementResponseService, private AuthProvider $authProvider, - private AccessChecker $accessChecker + private AccessChecker $accessChecker, + private Client401UnauthorizedExceptionFactory $client401UnauthorizedExceptionFactory, + private Client404NotFoundExceptionFactory $client404NotFoundExceptionFactory ) { } @@ -37,11 +39,11 @@ public function getElement(string $uuid): Response $userUuid = $this->authProvider->getUserUuid(); if (!$userUuid) { - throw new ClientUnauthorizedException(); + throw $this->client401UnauthorizedExceptionFactory->createFromTemplate(); } if (!$this->accessChecker->hasAccessToElement($userUuid, $elementUuid, AccessType::READ)) { - throw new ClientNotFoundException(); + throw $this->client404NotFoundExceptionFactory->createFromTemplate(); } return $this->elementResponseService->buildElementResponseFromUuid($elementUuid); diff --git a/src/Controller/Element/GetIndexController.php b/src/Controller/Element/GetIndexController.php index e98e0f2c..a6649cdf 100644 --- a/src/Controller/Element/GetIndexController.php +++ b/src/Controller/Element/GetIndexController.php @@ -2,7 +2,7 @@ namespace App\Controller\Element; -use App\Exception\ClientUnauthorizedException; +use App\Factory\Exception\Client401UnauthorizedExceptionFactory; use App\Security\AuthProvider; use App\Service\CollectionService; use Laudis\Neo4j\Databags\Statement; @@ -17,7 +17,8 @@ class GetIndexController extends AbstractController public function __construct( private CypherEntityManager $cypherEntityManager, private AuthProvider $authProvider, - private CollectionService $collectionService + private CollectionService $collectionService, + private Client401UnauthorizedExceptionFactory $client401UnauthorizedExceptionFactory ) { } @@ -30,7 +31,7 @@ public function getIndex(): Response { $userUuid = $this->authProvider->getUserUuid(); if (null === $userUuid) { - throw new ClientUnauthorizedException(); + throw $this->client401UnauthorizedExceptionFactory->createFromTemplate(); } $cypherClient = $this->cypherEntityManager->getClient(); $res = $cypherClient->runStatement(Statement::create( diff --git a/src/Controller/Element/GetParentsController.php b/src/Controller/Element/GetParentsController.php index 03f72205..796135e0 100644 --- a/src/Controller/Element/GetParentsController.php +++ b/src/Controller/Element/GetParentsController.php @@ -2,8 +2,8 @@ namespace App\Controller\Element; -use App\Exception\ClientNotFoundException; -use App\Exception\ClientUnauthorizedException; +use App\Factory\Exception\Client401UnauthorizedExceptionFactory; +use App\Factory\Exception\Client404NotFoundExceptionFactory; use App\Helper\Regex; use App\Security\AccessChecker; use App\Security\AuthProvider; @@ -23,7 +23,9 @@ public function __construct( private CypherEntityManager $cypherEntityManager, private CollectionService $collectionService, private AuthProvider $authProvider, - private AccessChecker $accessChecker + private AccessChecker $accessChecker, + private Client401UnauthorizedExceptionFactory $client401UnauthorizedExceptionFactory, + private Client404NotFoundExceptionFactory $client404NotFoundExceptionFactory ) { } @@ -41,17 +43,17 @@ public function getParents(string $uuid): Response $userUuid = $this->authProvider->getUserUuid(); if (!$userUuid) { - throw new ClientUnauthorizedException(); + throw $this->client401UnauthorizedExceptionFactory->createFromTemplate(); } $type = $this->accessChecker->getElementType($childUuid); if (ElementType::RELATION === $type) { // relations can not be child nodes - throw new ClientNotFoundException(); + throw $this->client404NotFoundExceptionFactory->createFromTemplate(); } if (!$this->accessChecker->hasAccessToElement($userUuid, $childUuid, AccessType::READ)) { - throw new ClientNotFoundException(); + throw $this->client404NotFoundExceptionFactory->createFromTemplate(); } $cypherClient = $this->cypherEntityManager->getClient(); diff --git a/src/Controller/Element/GetRelatedController.php b/src/Controller/Element/GetRelatedController.php index 8d2dbe44..e2350378 100644 --- a/src/Controller/Element/GetRelatedController.php +++ b/src/Controller/Element/GetRelatedController.php @@ -2,8 +2,8 @@ namespace App\Controller\Element; -use App\Exception\ClientNotFoundException; -use App\Exception\ClientUnauthorizedException; +use App\Factory\Exception\Client401UnauthorizedExceptionFactory; +use App\Factory\Exception\Client404NotFoundExceptionFactory; use App\Helper\Regex; use App\Security\AccessChecker; use App\Security\AuthProvider; @@ -23,7 +23,9 @@ public function __construct( private CypherEntityManager $cypherEntityManager, private CollectionService $collectionService, private AuthProvider $authProvider, - private AccessChecker $accessChecker + private AccessChecker $accessChecker, + private Client401UnauthorizedExceptionFactory $client401UnauthorizedExceptionFactory, + private Client404NotFoundExceptionFactory $client404NotFoundExceptionFactory ) { } @@ -41,17 +43,17 @@ public function getRelated(string $uuid): Response $userUuid = $this->authProvider->getUserUuid(); if (!$userUuid) { - throw new ClientUnauthorizedException(); + throw $this->client401UnauthorizedExceptionFactory->createFromTemplate(); } $type = $this->accessChecker->getElementType($centerUuid); if (ElementType::RELATION === $type) { // relations can not be center nodes - throw new ClientNotFoundException(); + throw $this->client404NotFoundExceptionFactory->createFromTemplate(); } if (!$this->accessChecker->hasAccessToElement($userUuid, $centerUuid, AccessType::READ)) { - throw new ClientNotFoundException(); + throw $this->client404NotFoundExceptionFactory->createFromTemplate(); } $cypherClient = $this->cypherEntityManager->getClient(); diff --git a/src/Controller/Element/PatchElementController.php b/src/Controller/Element/PatchElementController.php index 9d3ac000..d8608fd9 100644 --- a/src/Controller/Element/PatchElementController.php +++ b/src/Controller/Element/PatchElementController.php @@ -2,8 +2,8 @@ namespace App\Controller\Element; -use App\Exception\ClientNotFoundException; -use App\Exception\ClientUnauthorizedException; +use App\Factory\Exception\Client401UnauthorizedExceptionFactory; +use App\Factory\Exception\Client404NotFoundExceptionFactory; use App\Helper\Regex; use App\Response\NoContentResponse; use App\Security\AccessChecker; @@ -21,7 +21,9 @@ class PatchElementController extends AbstractController public function __construct( private ElementManager $elementManager, private AuthProvider $authProvider, - private AccessChecker $accessChecker + private AccessChecker $accessChecker, + private Client401UnauthorizedExceptionFactory $client401UnauthorizedExceptionFactory, + private Client404NotFoundExceptionFactory $client404NotFoundExceptionFactory ) { } @@ -39,16 +41,16 @@ public function patchElement(string $uuid, Request $request): Response $userUuid = $this->authProvider->getUserUuid(); if (!$userUuid) { - throw new ClientUnauthorizedException(); + throw $this->client401UnauthorizedExceptionFactory->createFromTemplate(); } if (!$this->accessChecker->hasAccessToElement($userUuid, $elementUuid, AccessType::UPDATE)) { - throw new ClientNotFoundException(); + throw $this->client404NotFoundExceptionFactory->createFromTemplate(); } $element = $this->elementManager->getElement($elementUuid); if (null === $element) { - throw new ClientNotFoundException(); + throw $this->client404NotFoundExceptionFactory->createFromTemplate(); } /** diff --git a/src/Controller/Element/PostElementController.php b/src/Controller/Element/PostElementController.php index a874618a..c48a1c76 100644 --- a/src/Controller/Element/PostElementController.php +++ b/src/Controller/Element/PostElementController.php @@ -2,10 +2,10 @@ namespace App\Controller\Element; -use App\Exception\ClientBadIdException; -use App\Exception\ClientBadRequestException; -use App\Exception\ClientNotFoundException; -use App\Exception\ClientUnauthorizedException; +use App\Factory\Exception\Client400MissingPropertyExceptionFactory; +use App\Factory\Exception\Client400ReservedIdentifierExceptionFactory; +use App\Factory\Exception\Client401UnauthorizedExceptionFactory; +use App\Factory\Exception\Client404NotFoundExceptionFactory; use App\Helper\Regex; use App\Response\CreatedResponse; use App\Security\AccessChecker; @@ -28,7 +28,11 @@ public function __construct( private AuthProvider $authProvider, private AccessChecker $accessChecker, private ElementManager $elementManager, - private UrlGeneratorInterface $router + private UrlGeneratorInterface $router, + private Client400ReservedIdentifierExceptionFactory $client400ReservedIdentifierExceptionFactory, + private Client400MissingPropertyExceptionFactory $client400MissingPropertyExceptionFactory, + private Client401UnauthorizedExceptionFactory $client401UnauthorizedExceptionFactory, + private Client404NotFoundExceptionFactory $client404NotFoundExceptionFactory ) { } @@ -46,17 +50,17 @@ public function postElement(string $uuid, Request $request): Response $userUuid = $this->authProvider->getUserUuid(); if (!$userUuid) { - throw new ClientUnauthorizedException(); + throw $this->client401UnauthorizedExceptionFactory->createFromTemplate(); } $type = $this->accessChecker->getElementType($elementUuid); if (ElementType::RELATION === $type) { // relations can not own nodes - throw new ClientNotFoundException(); + throw $this->client404NotFoundExceptionFactory->createFromTemplate(); } if (!$this->accessChecker->hasAccessToElement($userUuid, $elementUuid, AccessType::CREATE)) { - throw new ClientNotFoundException(); + throw $this->client404NotFoundExceptionFactory->createFromTemplate(); } $body = \Safe\json_decode($request->getContent(), true); @@ -64,19 +68,19 @@ public function postElement(string $uuid, Request $request): Response $newNodeUuid = UuidV4::uuid4(); if (array_key_exists('id', $body)) { $newNodeUuid = UuidV4::fromString($body['id']); - $elementTypeOfNewNodeUuid = $this->accessChecker->getElementType($newNodeUuid); - if (null !== $elementTypeOfNewNodeUuid) { - throw new ClientBadIdException(); + $uuidConflict = null !== $this->accessChecker->getElementType($newNodeUuid); + if ($uuidConflict) { + throw $this->client400ReservedIdentifierExceptionFactory->createFromTemplate($newNodeUuid->toString()); } } if (!array_key_exists('type', $body)) { - throw new ClientBadRequestException(detail: 'Required property "type" is not set.'); + throw $this->client400MissingPropertyExceptionFactory->createFromTemplate('type', 'a valid type'); } $type = $body['type']; if (!array_key_exists('data', $body)) { - throw new ClientBadRequestException(detail: 'Required property "data" is not set.'); + throw $this->client400MissingPropertyExceptionFactory->createFromTemplate('data', 'an object'); } $data = $body['data']; diff --git a/src/Controller/Element/PostIndexController.php b/src/Controller/Element/PostIndexController.php index 54ec4a77..ebc04370 100644 --- a/src/Controller/Element/PostIndexController.php +++ b/src/Controller/Element/PostIndexController.php @@ -2,9 +2,10 @@ namespace App\Controller\Element; -use App\Exception\ClientBadRequestException; -use App\Exception\ClientNotFoundException; -use App\Exception\ClientUnauthorizedException; +use App\Factory\Exception\Client400IncompleteMutualDependencyExceptionFactory; +use App\Factory\Exception\Client400MissingPropertyExceptionFactory; +use App\Factory\Exception\Client401UnauthorizedExceptionFactory; +use App\Factory\Exception\Client404NotFoundExceptionFactory; use App\Response\CreatedResponse; use App\Security\AccessChecker; use App\Security\AuthProvider; @@ -12,6 +13,7 @@ use App\Type\AccessType; use App\Type\NodeElement; use App\Type\RelationElement; +use DateTime; use Ramsey\Uuid\Rfc4122\UuidV4; use Ramsey\Uuid\UuidInterface; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; @@ -26,7 +28,11 @@ public function __construct( private AuthProvider $authProvider, private AccessChecker $accessChecker, private ElementManager $elementManager, - private UrlGeneratorInterface $router + private UrlGeneratorInterface $router, + private Client400MissingPropertyExceptionFactory $client400MissingPropertyExceptionFactory, + private Client400IncompleteMutualDependencyExceptionFactory $client400IncompleteMutualDependencyExceptionFactory, + private Client401UnauthorizedExceptionFactory $client401UnauthorizedExceptionFactory, + private Client404NotFoundExceptionFactory $client404NotFoundExceptionFactory ) { } @@ -37,6 +43,11 @@ public function __construct( )] public function postIndex(Request $request): Response { + $userId = $this->authProvider->getUserUuid(); + if (!$userId) { + throw $this->client401UnauthorizedExceptionFactory->createFromTemplate(); + } + $body = \Safe\json_decode($request->getContent(), true); if (array_key_exists('id', $body)) { @@ -46,7 +57,7 @@ public function postIndex(Request $request): Response } if (!array_key_exists('type', $body)) { - throw new ClientBadRequestException(detail: 'Type must be set.'); + throw $this->client400MissingPropertyExceptionFactory->createFromTemplate('type', 'a valid type'); } $type = $body['type']; @@ -56,7 +67,7 @@ public function postIndex(Request $request): Response foreach ($data as $key => $value) { if (is_string($value)) { if (strlen($value) >= 22 && strlen($value) <= 26) { - $possibleDate = \DateTime::createFromFormat(\DateTime::ATOM, $value); + $possibleDate = DateTime::createFromFormat(DateTime::ATOM, $value); if (false !== $possibleDate) { $data[$key] = $possibleDate; } @@ -83,7 +94,19 @@ public function postIndex(Request $request): Response return $this->createRelation($type, $elementId, $startId, $endId, $data); } - throw new ClientBadRequestException(detail: "When creating a relation, both properties 'start' as well as 'end' must be set."); + $setProperties = []; + $missingProperties = []; + if (null !== $startId) { + $setProperties[] = 'start'; + } else { + $missingProperties[] = 'start'; + } + if (null !== $endId) { + $setProperties[] = 'end'; + } else { + $missingProperties[] = 'end'; + } + throw $this->client400IncompleteMutualDependencyExceptionFactory->createFromTemplate(['start', 'end'], $setProperties, $missingProperties); } /** @@ -132,15 +155,12 @@ private function createNode(string $type, UuidInterface $nodeId, array $data): R private function createRelation(string $type, UuidInterface $relationId, UuidInterface $startId, UuidInterface $endId, array $data): Response { $userId = $this->authProvider->getUserUuid(); - if (!$userId) { - throw new ClientUnauthorizedException(); - } if (!$this->accessChecker->hasAccessToElement($userId, $startId, AccessType::CREATE)) { - throw new ClientNotFoundException(); + throw $this->client404NotFoundExceptionFactory->createFromTemplate(); } if (!$this->accessChecker->hasAccessToElement($userId, $endId, AccessType::READ)) { - throw new ClientNotFoundException(); + throw $this->client404NotFoundExceptionFactory->createFromTemplate(); } $newRelation = (new RelationElement()) diff --git a/src/Controller/Element/PutElementController.php b/src/Controller/Element/PutElementController.php index 2b8b2558..855cbb20 100644 --- a/src/Controller/Element/PutElementController.php +++ b/src/Controller/Element/PutElementController.php @@ -2,8 +2,8 @@ namespace App\Controller\Element; -use App\Exception\ClientNotFoundException; -use App\Exception\ClientUnauthorizedException; +use App\Factory\Exception\Client401UnauthorizedExceptionFactory; +use App\Factory\Exception\Client404NotFoundExceptionFactory; use App\Helper\Regex; use App\Response\NoContentResponse; use App\Security\AccessChecker; @@ -22,6 +22,8 @@ public function __construct( private ElementManager $elementManager, private AuthProvider $authProvider, private AccessChecker $accessChecker, + private Client401UnauthorizedExceptionFactory $client401UnauthorizedExceptionFactory, + private Client404NotFoundExceptionFactory $client404NotFoundExceptionFactory ) { } @@ -39,16 +41,16 @@ public function putElement(string $uuid, Request $request): Response $userUuid = $this->authProvider->getUserUuid(); if (!$userUuid) { - throw new ClientUnauthorizedException(); + throw $this->client401UnauthorizedExceptionFactory->createFromTemplate(); } if (!$this->accessChecker->hasAccessToElement($userUuid, $elementUuid, AccessType::UPDATE)) { - throw new ClientNotFoundException(); + throw $this->client404NotFoundExceptionFactory->createFromTemplate(); } $element = $this->elementManager->getElement($elementUuid); if (null === $element) { - throw new ClientNotFoundException(); + throw $this->client404NotFoundExceptionFactory->createFromTemplate(); } /** diff --git a/src/Controller/Error/ExceptionDetailController.php b/src/Controller/Error/ExceptionDetailController.php new file mode 100644 index 00000000..5f570f80 --- /dev/null +++ b/src/Controller/Error/ExceptionDetailController.php @@ -0,0 +1,51 @@ +client404NotFoundExceptionFactory->createFromTemplate(); + } + if (preg_match('/[^a-z-]/', $name)) { + throw $this->client404NotFoundExceptionFactory->createFromTemplate(); + } + + $errorContentPath = sprintf( + '%s/assets/error-%s-%s.txt', + __DIR__, + $code, + $name + ); + if (!file_exists($errorContentPath)) { + throw $this->client404NotFoundExceptionFactory->createFromTemplate(); + } + + $emberNexusApiLogo = \Safe\file_get_contents(__DIR__.'/assets/ember-nexus-api-logo.txt'); + $content = \Safe\file_get_contents($errorContentPath); + + return new TextResponse(sprintf( + '%s%s', + $emberNexusApiLogo, + $content + )); + } +} diff --git a/src/Controller/Error/assets/ember-nexus-api-logo.txt b/src/Controller/Error/assets/ember-nexus-api-logo.txt new file mode 100644 index 00000000..e5b1089c --- /dev/null +++ b/src/Controller/Error/assets/ember-nexus-api-logo.txt @@ -0,0 +1,7 @@ + _____ _ _ _ _ ____ ___ + | ____|_ __ ___ | |__ ___ _ __ | \ | | _____ ___ _ ___ / \ | _ \_ _| + | _| | '_ ` _ \| '_ \ / _ \ '__| | \| |/ _ \ \/ / | | / __| / _ \ | |_) | | + | |___| | | | | | |_) | __/ | | |\ | __/⟩ ⟨| |_| \__ \ / ___ \| __/| | + |_____|_| |_| |_|_.__/ \___|_| |_| \_|\___/_/\_\\__,_|___/ /_/ \_\_| |___| + + diff --git a/src/Controller/Error/assets/error-400-bad-content.txt b/src/Controller/Error/assets/error-400-bad-content.txt new file mode 100644 index 00000000..a3698b89 --- /dev/null +++ b/src/Controller/Error/assets/error-400-bad-content.txt @@ -0,0 +1,6 @@ + Error 400 - Bad Content + + This error is thrown, when a required request property is set, but does not contain a valid value. + + Link to the documentation: https://ember-nexus.github.io/api + diff --git a/src/Controller/Error/assets/error-400-forbidden-property.txt b/src/Controller/Error/assets/error-400-forbidden-property.txt new file mode 100644 index 00000000..11c12683 --- /dev/null +++ b/src/Controller/Error/assets/error-400-forbidden-property.txt @@ -0,0 +1,7 @@ + Error 400 - Forbidden Property + + This error is thrown when the request body contains a property, which is either generally not allowed or can not be + changed manually. + + Link to the documentation: https://ember-nexus.github.io/api + diff --git a/src/Controller/Error/assets/error-400-incomplete-mutual-dependency.txt b/src/Controller/Error/assets/error-400-incomplete-mutual-dependency.txt new file mode 100644 index 00000000..2aae457d --- /dev/null +++ b/src/Controller/Error/assets/error-400-incomplete-mutual-dependency.txt @@ -0,0 +1,7 @@ + Error 400 - Incomplete Mutual Dependency + + This error is thrown when there are properties which depend on ech other, i.e. must be all defined, but at least one + is missing from the request body. Try to add the missing properties. + + Link to the documentation: https://ember-nexus.github.io/api + diff --git a/src/Controller/Error/assets/error-400-missing-property.txt b/src/Controller/Error/assets/error-400-missing-property.txt new file mode 100644 index 00000000..0b743a3d --- /dev/null +++ b/src/Controller/Error/assets/error-400-missing-property.txt @@ -0,0 +1,6 @@ + Error 400 - Missing Property + + This error is thrown when the request body does not contain a required property. + + Link to the documentation: https://ember-nexus.github.io/api + diff --git a/src/Controller/File/DeleteElementFileController.php b/src/Controller/File/DeleteElementFileController.php index c3241fb4..6b2079e1 100644 --- a/src/Controller/File/DeleteElementFileController.php +++ b/src/Controller/File/DeleteElementFileController.php @@ -2,7 +2,7 @@ namespace App\Controller\File; -use App\Exception\NotImplementedException; +use App\Factory\Exception\Server501NotImplementedExceptionFactory; use App\Helper\Regex; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; use Symfony\Component\HttpFoundation\Request; @@ -11,6 +11,11 @@ class DeleteElementFileController extends AbstractController { + public function __construct( + private Server501NotImplementedExceptionFactory $server501NotImplementedExceptionFactory + ) { + } + #[Route( '/{uuid}/file', name: 'deleteElementFile', @@ -21,6 +26,6 @@ class DeleteElementFileController extends AbstractController )] public function deleteElementFile(string $uuid, Request $request): Response { - throw new NotImplementedException(); + throw $this->server501NotImplementedExceptionFactory->createFromTemplate(); } } diff --git a/src/Controller/File/GetElementFileController.php b/src/Controller/File/GetElementFileController.php index d2dad463..047a3172 100644 --- a/src/Controller/File/GetElementFileController.php +++ b/src/Controller/File/GetElementFileController.php @@ -2,7 +2,7 @@ namespace App\Controller\File; -use App\Exception\NotImplementedException; +use App\Factory\Exception\Server501NotImplementedExceptionFactory; use App\Helper\Regex; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; use Symfony\Component\HttpFoundation\Request; @@ -11,6 +11,11 @@ class GetElementFileController extends AbstractController { + public function __construct( + private Server501NotImplementedExceptionFactory $server501NotImplementedExceptionFactory + ) { + } + #[Route( '/{uuid}/file', name: 'getElementFile', @@ -21,6 +26,6 @@ class GetElementFileController extends AbstractController )] public function getElementFile(string $uuid, Request $request): Response { - throw new NotImplementedException(); + throw $this->server501NotImplementedExceptionFactory->createFromTemplate(); } } diff --git a/src/Controller/File/PatchElementFileController.php b/src/Controller/File/PatchElementFileController.php index bca9ca74..bf486c11 100644 --- a/src/Controller/File/PatchElementFileController.php +++ b/src/Controller/File/PatchElementFileController.php @@ -2,7 +2,7 @@ namespace App\Controller\File; -use App\Exception\NotImplementedException; +use App\Factory\Exception\Server501NotImplementedExceptionFactory; use App\Helper\Regex; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; use Symfony\Component\HttpFoundation\Request; @@ -11,6 +11,11 @@ class PatchElementFileController extends AbstractController { + public function __construct( + private Server501NotImplementedExceptionFactory $server501NotImplementedExceptionFactory + ) { + } + #[Route( '/{uuid}/file', name: 'patchElementFile', @@ -21,6 +26,6 @@ class PatchElementFileController extends AbstractController )] public function patchElementFile(string $uuid, Request $request): Response { - throw new NotImplementedException(); + throw $this->server501NotImplementedExceptionFactory->createFromTemplate(); } } diff --git a/src/Controller/File/PostElementFileController.php b/src/Controller/File/PostElementFileController.php index 79a6dc10..ffa2f674 100644 --- a/src/Controller/File/PostElementFileController.php +++ b/src/Controller/File/PostElementFileController.php @@ -2,7 +2,7 @@ namespace App\Controller\File; -use App\Exception\NotImplementedException; +use App\Factory\Exception\Server501NotImplementedExceptionFactory; use App\Helper\Regex; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; use Symfony\Component\HttpFoundation\Request; @@ -11,6 +11,11 @@ class PostElementFileController extends AbstractController { + public function __construct( + private Server501NotImplementedExceptionFactory $server501NotImplementedExceptionFactory + ) { + } + #[Route( '/{uuid}/file', name: 'postElementFile', @@ -21,6 +26,6 @@ class PostElementFileController extends AbstractController )] public function postElementFile(string $uuid, Request $request): Response { - throw new NotImplementedException(); + throw $this->server501NotImplementedExceptionFactory->createFromTemplate(); } } diff --git a/src/Controller/File/PutElementFileController.php b/src/Controller/File/PutElementFileController.php index 82c4a2bc..544eaf6e 100644 --- a/src/Controller/File/PutElementFileController.php +++ b/src/Controller/File/PutElementFileController.php @@ -2,7 +2,7 @@ namespace App\Controller\File; -use App\Exception\NotImplementedException; +use App\Factory\Exception\Server501NotImplementedExceptionFactory; use App\Helper\Regex; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; use Symfony\Component\HttpFoundation\Request; @@ -11,6 +11,11 @@ class PutElementFileController extends AbstractController { + public function __construct( + private Server501NotImplementedExceptionFactory $server501NotImplementedExceptionFactory + ) { + } + #[Route( '/{uuid}/file', name: 'putElementFile', @@ -21,6 +26,6 @@ class PutElementFileController extends AbstractController )] public function putElementFile(string $uuid, Request $request): Response { - throw new NotImplementedException(); + throw $this->server501NotImplementedExceptionFactory->createFromTemplate(); } } diff --git a/src/Controller/Problem/ClientBadRequestController.php b/src/Controller/Problem/ClientBadRequestController.php deleted file mode 100755 index 4235d4e7..00000000 --- a/src/Controller/Problem/ClientBadRequestController.php +++ /dev/null @@ -1,24 +0,0 @@ -authProvider->getUserUuid(); if (!$currentUserUuid) { - throw new ClientUnauthorizedException(); + throw $this->client401UnauthorizedExceptionFactory->createFromTemplate(); } $userGroups = $this->accessChecker->getUsersGroups($currentUserUuid); @@ -47,7 +52,7 @@ public function postSearch(Request $request): Response } if (!array_key_exists('query', $body)) { - throw new ClientBadRequestException(detail: "Body property 'query' is required."); + throw $this->client400MissingPropertyExceptionFactory->createFromTemplate('query', 'an valid Elasticsearch query object'); } $userQuery = $body['query']; @@ -55,7 +60,7 @@ public function postSearch(Request $request): Response if (array_key_exists('nodeTypes', $body)) { $rawNodeTypes = $body['nodeTypes']; if (!is_array($rawNodeTypes)) { - throw new ClientBadRequestException(detail: 'Property "nodeTypes" must be an array of node types.'); + throw $this->client400BadContentExceptionFactory->createFromTemplate('nodeTypes', 'array', $rawNodeTypes); } foreach ($rawNodeTypes as $rawNodeType) { $nodeTypes[] = sprintf('node_%s', strtolower($rawNodeType)); @@ -66,7 +71,7 @@ public function postSearch(Request $request): Response if (array_key_exists('relationTypes', $body)) { $rawRelationTypes = $body['relationTypes']; if (!is_array($rawRelationTypes)) { - throw new ClientBadRequestException(detail: 'Property "relationTypes" must be an array of relation types.'); + throw $this->client400BadContentExceptionFactory->createFromTemplate('relationTypes', 'array', $rawRelationTypes); } foreach ($rawRelationTypes as $rawRelationType) { $relationTypes[] = sprintf('relation_%s', strtolower($rawRelationType)); @@ -124,7 +129,7 @@ public function postSearch(Request $request): Response ]); if (!($res instanceof Elasticsearch)) { - throw new ServerException(detail: 'Unknown response type for elastic search query.'); + throw $this->server500InternalServerErrorExceptionFactory->createFromTemplate('Unknown response type for elastic search query.'); } $elementIds = []; diff --git a/src/Controller/System/GetInstanceConfigurationController.php b/src/Controller/System/GetInstanceConfigurationController.php index c078de24..878bf370 100644 --- a/src/Controller/System/GetInstanceConfigurationController.php +++ b/src/Controller/System/GetInstanceConfigurationController.php @@ -2,7 +2,7 @@ namespace App\Controller\System; -use App\Exception\ClientForbiddenException; +use App\Factory\Exception\Client403ForbiddenExceptionFactory; use App\Response\JsonResponse; use EmberNexusBundle\Service\EmberNexusConfiguration; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; @@ -14,7 +14,8 @@ class GetInstanceConfigurationController extends AbstractController { public function __construct( private EmberNexusConfiguration $emberNexusConfiguration, - private ParameterBagInterface $bag + private ParameterBagInterface $bag, + private Client403ForbiddenExceptionFactory $client403ForbiddenExceptionFactory ) { } @@ -26,7 +27,7 @@ public function __construct( public function getInstanceConfiguration(): Response { if (!$this->emberNexusConfiguration->isInstanceConfigurationEnabled()) { - throw new ClientForbiddenException(); + throw $this->client403ForbiddenExceptionFactory->createFromTemplate(); } $instanceConfiguration = [ diff --git a/src/Controller/User/PostRegisterController.php b/src/Controller/User/PostRegisterController.php index 2b1ea023..fb668301 100644 --- a/src/Controller/User/PostRegisterController.php +++ b/src/Controller/User/PostRegisterController.php @@ -2,8 +2,9 @@ namespace App\Controller\User; -use App\Exception\ClientBadRequestException; -use App\Exception\ClientForbiddenException; +use App\Factory\Exception\Client400MissingPropertyExceptionFactory; +use App\Factory\Exception\Client400ReservedIdentifierExceptionFactory; +use App\Factory\Exception\Client403ForbiddenExceptionFactory; use App\Response\CreatedResponse; use App\Security\UserPasswordHasher; use App\Service\ElementManager; @@ -25,7 +26,10 @@ public function __construct( private CypherEntityManager $cypherEntityManager, private UrlGeneratorInterface $router, private UserPasswordHasher $userPasswordHasher, - private EmberNexusConfiguration $emberNexusConfiguration + private EmberNexusConfiguration $emberNexusConfiguration, + private Client400MissingPropertyExceptionFactory $client400MissingPropertyExceptionFactory, + private Client400ReservedIdentifierExceptionFactory $client400ReservedIdentifierExceptionFactory, + private Client403ForbiddenExceptionFactory $client403ForbiddenExceptionFactory, ) { } @@ -39,7 +43,7 @@ public function postRegister(Request $request): Response $body = \Safe\json_decode($request->getContent(), true); if (!$this->emberNexusConfiguration->isRegisterEnabled()) { - throw new ClientForbiddenException(); + throw $this->client403ForbiddenExceptionFactory->createFromTemplate(); } $userId = UuidV4::uuid4(); @@ -52,13 +56,13 @@ public function postRegister(Request $request): Response * @var array $data */ if (!array_key_exists('password', $body)) { - throw new ClientBadRequestException(detail: 'Property password must be set.'); + throw $this->client400MissingPropertyExceptionFactory->createFromTemplate('password', 'string'); } $password = $body['password']; $uniqueIdentifier = $this->emberNexusConfiguration->getRegisterUniqueIdentifier(); if (!array_key_exists($uniqueIdentifier, $data)) { - throw new ClientBadRequestException(detail: sprintf("Property '%s' must be set.", $uniqueIdentifier)); + throw $this->client400MissingPropertyExceptionFactory->createFromTemplate($uniqueIdentifier, 'string'); } $uniqueIdentifierValue = $data[$uniqueIdentifier]; @@ -72,7 +76,7 @@ public function postRegister(Request $request): Response ] )); if ($res->first()->get('count') > 0) { - throw new ClientBadRequestException(sprintf("Value '%s' for property '%s' is not available.", $uniqueIdentifierValue, $uniqueIdentifier)); + throw $this->client400ReservedIdentifierExceptionFactory->createFromTemplate($uniqueIdentifierValue); } $userNode = (new NodeElement()) diff --git a/src/Controller/User/PostTokenController.php b/src/Controller/User/PostTokenController.php index 36627911..c5ffebfa 100644 --- a/src/Controller/User/PostTokenController.php +++ b/src/Controller/User/PostTokenController.php @@ -2,7 +2,7 @@ namespace App\Controller\User; -use App\Exception\ClientUnauthorizedException; +use App\Factory\Exception\Client401UnauthorizedExceptionFactory; use App\Response\JsonResponse; use App\Security\AuthProvider; use App\Security\TokenGenerator; @@ -15,7 +15,8 @@ class PostTokenController extends AbstractController { public function __construct( private AuthProvider $authProvider, - private TokenGenerator $tokenGenerator + private TokenGenerator $tokenGenerator, + private Client401UnauthorizedExceptionFactory $client401UnauthorizedExceptionFactory ) { } @@ -29,7 +30,7 @@ public function postToken(Request $request): Response $userUuid = $this->authProvider->getUserUuid(); if (!$userUuid) { - throw new ClientUnauthorizedException(); + throw $this->client401UnauthorizedExceptionFactory->createFromTemplate(); } $body = \Safe\json_decode($request->getContent(), true); diff --git a/src/Controller/WebDAV/CopyElementController.php b/src/Controller/WebDAV/CopyElementController.php index 9e124e80..abdd962b 100644 --- a/src/Controller/WebDAV/CopyElementController.php +++ b/src/Controller/WebDAV/CopyElementController.php @@ -2,7 +2,7 @@ namespace App\Controller\WebDAV; -use App\Exception\NotImplementedException; +use App\Factory\Exception\Server501NotImplementedExceptionFactory; use App\Helper\Regex; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; use Symfony\Component\HttpFoundation\Request; @@ -11,6 +11,11 @@ class CopyElementController extends AbstractController { + public function __construct( + private Server501NotImplementedExceptionFactory $server501NotImplementedExceptionFactory + ) { + } + #[Route( '/{uuid}', name: 'copyElement', @@ -21,6 +26,6 @@ class CopyElementController extends AbstractController )] public function copyElement(string $uuid, Request $request): Response { - throw new NotImplementedException(); + throw $this->server501NotImplementedExceptionFactory->createFromTemplate(); } } diff --git a/src/Controller/WebDAV/LockElementController.php b/src/Controller/WebDAV/LockElementController.php index 9183a4ef..acb3622d 100644 --- a/src/Controller/WebDAV/LockElementController.php +++ b/src/Controller/WebDAV/LockElementController.php @@ -2,7 +2,7 @@ namespace App\Controller\WebDAV; -use App\Exception\NotImplementedException; +use App\Factory\Exception\Server501NotImplementedExceptionFactory; use App\Helper\Regex; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; use Symfony\Component\HttpFoundation\Request; @@ -11,6 +11,11 @@ class LockElementController extends AbstractController { + public function __construct( + private Server501NotImplementedExceptionFactory $server501NotImplementedExceptionFactory + ) { + } + #[Route( '/{uuid}', name: 'lockElement', @@ -21,6 +26,6 @@ class LockElementController extends AbstractController )] public function lockElement(string $uuid, Request $request): Response { - throw new NotImplementedException(); + throw $this->server501NotImplementedExceptionFactory->createFromTemplate(); } } diff --git a/src/Controller/WebDAV/MkcolElementController.php b/src/Controller/WebDAV/MkcolElementController.php index 2d24c00f..5ad6a682 100644 --- a/src/Controller/WebDAV/MkcolElementController.php +++ b/src/Controller/WebDAV/MkcolElementController.php @@ -2,7 +2,7 @@ namespace App\Controller\WebDAV; -use App\Exception\NotImplementedException; +use App\Factory\Exception\Server501NotImplementedExceptionFactory; use App\Helper\Regex; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; use Symfony\Component\HttpFoundation\Request; @@ -11,6 +11,11 @@ class MkcolElementController extends AbstractController { + public function __construct( + private Server501NotImplementedExceptionFactory $server501NotImplementedExceptionFactory + ) { + } + #[Route( '/{uuid}', name: 'mkcolElement', @@ -21,6 +26,6 @@ class MkcolElementController extends AbstractController )] public function mkcolElement(string $uuid, Request $request): Response { - throw new NotImplementedException(); + throw $this->server501NotImplementedExceptionFactory->createFromTemplate(); } } diff --git a/src/Controller/WebDAV/MoveElementController.php b/src/Controller/WebDAV/MoveElementController.php index da653319..613db6cc 100644 --- a/src/Controller/WebDAV/MoveElementController.php +++ b/src/Controller/WebDAV/MoveElementController.php @@ -2,7 +2,7 @@ namespace App\Controller\WebDAV; -use App\Exception\NotImplementedException; +use App\Factory\Exception\Server501NotImplementedExceptionFactory; use App\Helper\Regex; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; use Symfony\Component\HttpFoundation\Request; @@ -11,6 +11,11 @@ class MoveElementController extends AbstractController { + public function __construct( + private Server501NotImplementedExceptionFactory $server501NotImplementedExceptionFactory + ) { + } + #[Route( '/{uuid}', name: 'moveElement', @@ -21,6 +26,6 @@ class MoveElementController extends AbstractController )] public function moveElement(string $uuid, Request $request): Response { - throw new NotImplementedException(); + throw $this->server501NotImplementedExceptionFactory->createFromTemplate(); } } diff --git a/src/Controller/WebDAV/PropfindElementController.php b/src/Controller/WebDAV/PropfindElementController.php index 4041b3f8..fd573b00 100644 --- a/src/Controller/WebDAV/PropfindElementController.php +++ b/src/Controller/WebDAV/PropfindElementController.php @@ -2,7 +2,7 @@ namespace App\Controller\WebDAV; -use App\Exception\NotImplementedException; +use App\Factory\Exception\Server501NotImplementedExceptionFactory; use App\Helper\Regex; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; use Symfony\Component\HttpFoundation\Request; @@ -11,6 +11,11 @@ class PropfindElementController extends AbstractController { + public function __construct( + private Server501NotImplementedExceptionFactory $server501NotImplementedExceptionFactory + ) { + } + #[Route( '/{uuid}', name: 'propfindElement', @@ -21,6 +26,6 @@ class PropfindElementController extends AbstractController )] public function propfindElement(string $uuid, Request $request): Response { - throw new NotImplementedException(); + throw $this->server501NotImplementedExceptionFactory->createFromTemplate(); } } diff --git a/src/Controller/WebDAV/ProppatchElementController.php b/src/Controller/WebDAV/ProppatchElementController.php index d0461923..57f01687 100644 --- a/src/Controller/WebDAV/ProppatchElementController.php +++ b/src/Controller/WebDAV/ProppatchElementController.php @@ -2,7 +2,7 @@ namespace App\Controller\WebDAV; -use App\Exception\NotImplementedException; +use App\Factory\Exception\Server501NotImplementedExceptionFactory; use App\Helper\Regex; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; use Symfony\Component\HttpFoundation\Request; @@ -11,6 +11,11 @@ class ProppatchElementController extends AbstractController { + public function __construct( + private Server501NotImplementedExceptionFactory $server501NotImplementedExceptionFactory + ) { + } + #[Route( '/{uuid}', name: 'proppatchElement', @@ -21,6 +26,6 @@ class ProppatchElementController extends AbstractController )] public function proppatchElement(string $uuid, Request $request): Response { - throw new NotImplementedException(); + throw $this->server501NotImplementedExceptionFactory->createFromTemplate(); } } diff --git a/src/Controller/WebDAV/UnlockElementController.php b/src/Controller/WebDAV/UnlockElementController.php index 21665727..4ed19552 100644 --- a/src/Controller/WebDAV/UnlockElementController.php +++ b/src/Controller/WebDAV/UnlockElementController.php @@ -2,7 +2,7 @@ namespace App\Controller\WebDAV; -use App\Exception\NotImplementedException; +use App\Factory\Exception\Server501NotImplementedExceptionFactory; use App\Helper\Regex; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; use Symfony\Component\HttpFoundation\Request; @@ -11,6 +11,11 @@ class UnlockElementController extends AbstractController { + public function __construct( + private Server501NotImplementedExceptionFactory $server501NotImplementedExceptionFactory + ) { + } + #[Route( '/{uuid}', name: 'unlockElement', @@ -21,6 +26,6 @@ class UnlockElementController extends AbstractController )] public function unlockElement(string $uuid, Request $request): Response { - throw new NotImplementedException(); + throw $this->server501NotImplementedExceptionFactory->createFromTemplate(); } } diff --git a/src/EventSystem/ElementDefragmentize/EventListener/RelationElementDefragmentizeEventListener.php b/src/EventSystem/ElementDefragmentize/EventListener/RelationElementDefragmentizeEventListener.php index 56b2843e..0f539dca 100644 --- a/src/EventSystem/ElementDefragmentize/EventListener/RelationElementDefragmentizeEventListener.php +++ b/src/EventSystem/ElementDefragmentize/EventListener/RelationElementDefragmentizeEventListener.php @@ -3,6 +3,7 @@ namespace App\EventSystem\ElementDefragmentize\EventListener; use App\EventSystem\ElementDefragmentize\Event\RelationElementDefragmentizeEvent; +use InvalidArgumentException; use Ramsey\Uuid\Rfc4122\UuidV4; class RelationElementDefragmentizeEventListener @@ -17,27 +18,27 @@ public function onRelationElementDefragmentizeEvent(RelationElementDefragmentize $identifier = $cypherFragment->getProperty('id'); if (null === $identifier) { - throw new \InvalidArgumentException(); + throw new InvalidArgumentException(); } $identifier = UuidV4::fromString($identifier); $start = $cypherFragment->getStartNode(); if (null === $start) { - throw new \InvalidArgumentException(); + throw new InvalidArgumentException(); } $start = $start->getProperty('id'); if (null === $start) { - throw new \InvalidArgumentException(); + throw new InvalidArgumentException(); } $start = UuidV4::fromString($start); $end = $cypherFragment->getEndNode(); if (null === $end) { - throw new \InvalidArgumentException(); + throw new InvalidArgumentException(); } $end = $end->getProperty('id'); if (null === $end) { - throw new \InvalidArgumentException(); + throw new InvalidArgumentException(); } $end = UuidV4::fromString($end); diff --git a/src/EventSystem/ElementFragmentize/EventListener/CreatedPropertyElementFragmentizeEventListener.php b/src/EventSystem/ElementFragmentize/EventListener/CreatedPropertyElementFragmentizeEventListener.php index 0feb3600..056876a4 100644 --- a/src/EventSystem/ElementFragmentize/EventListener/CreatedPropertyElementFragmentizeEventListener.php +++ b/src/EventSystem/ElementFragmentize/EventListener/CreatedPropertyElementFragmentizeEventListener.php @@ -5,6 +5,8 @@ use App\EventSystem\ElementFragmentize\Event\NodeElementFragmentizeEvent; use App\EventSystem\ElementFragmentize\Event\RelationElementFragmentizeEvent; use App\Exception\ServerException; +use DateTimeInterface; +use Exception; use Laudis\Neo4j\Types\DateTimeZoneId; use MongoDB\BSON\UTCDateTime; @@ -41,8 +43,8 @@ private function handleEvent(NodeElementFragmentizeEvent|RelationElementFragment if ($created instanceof DateTimeZoneId) { $created = $created->toDateTime(); } - if (!($created instanceof \DateTimeInterface)) { - throw new \Exception("Unable to get datetime info from created property of type '".get_class($created)."'."); + if (!($created instanceof DateTimeInterface)) { + throw new Exception("Unable to get datetime info from created property of type '".get_class($created)."'."); } $cypherFragment->addProperty('created', $created); $mongoFragment->addProperty('created', new UTCDateTime($created)); diff --git a/src/EventSystem/ElementFragmentize/EventListener/GenericPropertyElementFragmentizeEventListener.php b/src/EventSystem/ElementFragmentize/EventListener/GenericPropertyElementFragmentizeEventListener.php index 1ca67435..3e893154 100644 --- a/src/EventSystem/ElementFragmentize/EventListener/GenericPropertyElementFragmentizeEventListener.php +++ b/src/EventSystem/ElementFragmentize/EventListener/GenericPropertyElementFragmentizeEventListener.php @@ -4,6 +4,8 @@ use App\EventSystem\ElementFragmentize\Event\NodeElementFragmentizeEvent; use App\EventSystem\ElementFragmentize\Event\RelationElementFragmentizeEvent; +use DateTimeInterface; +use Exception; use Laudis\Neo4j\Types\DateTimeZoneId; class GenericPropertyElementFragmentizeEventListener @@ -38,7 +40,7 @@ private function handleEvent(NodeElementFragmentizeEvent|RelationElementFragment $mongoFragment->addProperty($name, $value); continue; } - if ($value instanceof \DateTimeInterface) { + if ($value instanceof DateTimeInterface) { $cypherFragment->addProperty($name, $value); $elasticFragment->addProperty($name, $value->format('Uu')); continue; @@ -74,7 +76,7 @@ private function handleEvent(NodeElementFragmentizeEvent|RelationElementFragment $elasticFragment->addProperty($name, $value); continue; } - throw new \Exception('unknown data type'); + throw new Exception('unknown data type'); } } } diff --git a/src/EventSystem/ElementFragmentize/EventListener/NodeElementFragmentizeEventListener.php b/src/EventSystem/ElementFragmentize/EventListener/NodeElementFragmentizeEventListener.php index 8a0c368a..9c44b12c 100644 --- a/src/EventSystem/ElementFragmentize/EventListener/NodeElementFragmentizeEventListener.php +++ b/src/EventSystem/ElementFragmentize/EventListener/NodeElementFragmentizeEventListener.php @@ -3,6 +3,7 @@ namespace App\EventSystem\ElementFragmentize\EventListener; use App\EventSystem\ElementFragmentize\Event\NodeElementFragmentizeEvent; +use InvalidArgumentException; class NodeElementFragmentizeEventListener { @@ -16,13 +17,13 @@ public function onNodeElementFragmentizeEvent(NodeElementFragmentizeEvent $event $nodeElementIdentifier = $nodeElement->getIdentifier(); if (null === $nodeElementIdentifier) { - throw new \InvalidArgumentException(); + throw new InvalidArgumentException(); } $nodeElementIdentifier = $nodeElementIdentifier->toString(); $nodeLabel = $nodeElement->getLabel(); if (null === $nodeLabel) { - throw new \InvalidArgumentException(); + throw new InvalidArgumentException(); } /** diff --git a/src/EventSystem/ElementFragmentize/EventListener/RelationElementFragmentizeEventListener.php b/src/EventSystem/ElementFragmentize/EventListener/RelationElementFragmentizeEventListener.php index c980c6df..c967d6dd 100644 --- a/src/EventSystem/ElementFragmentize/EventListener/RelationElementFragmentizeEventListener.php +++ b/src/EventSystem/ElementFragmentize/EventListener/RelationElementFragmentizeEventListener.php @@ -3,6 +3,7 @@ namespace App\EventSystem\ElementFragmentize\EventListener; use App\EventSystem\ElementFragmentize\Event\RelationElementFragmentizeEvent; +use LogicException; use Syndesi\CypherDataStructures\Type\Node; class RelationElementFragmentizeEventListener @@ -17,24 +18,24 @@ public function onRelationElementFragmentizeEvent(RelationElementFragmentizeEven $relationUuid = $relationElement->getIdentifier(); if (null === $relationUuid) { - throw new \LogicException(); + throw new LogicException(); } $relationUuid = $relationUuid->toString(); $relationType = $relationElement->getType(); if (null === $relationType) { - throw new \LogicException(); + throw new LogicException(); } $startUuid = $relationElement->getStart(); if (null === $startUuid) { - throw new \LogicException(); + throw new LogicException(); } $startUuid = $startUuid->toString(); $endUuid = $relationElement->getEnd(); if (null === $endUuid) { - throw new \LogicException(); + throw new LogicException(); } $endUuid = $endUuid->toString(); diff --git a/src/EventSystem/ElementFragmentize/EventListener/UpdatedPropertyElementFragmentizeEventListener.php b/src/EventSystem/ElementFragmentize/EventListener/UpdatedPropertyElementFragmentizeEventListener.php index 1596e2c3..42fd14f8 100644 --- a/src/EventSystem/ElementFragmentize/EventListener/UpdatedPropertyElementFragmentizeEventListener.php +++ b/src/EventSystem/ElementFragmentize/EventListener/UpdatedPropertyElementFragmentizeEventListener.php @@ -5,6 +5,8 @@ use App\EventSystem\ElementFragmentize\Event\NodeElementFragmentizeEvent; use App\EventSystem\ElementFragmentize\Event\RelationElementFragmentizeEvent; use App\Exception\ServerException; +use DateTimeInterface; +use Exception; use Laudis\Neo4j\Types\DateTimeZoneId; use MongoDB\BSON\UTCDateTime; @@ -41,8 +43,8 @@ private function handleEvent(NodeElementFragmentizeEvent|RelationElementFragment if ($updated instanceof DateTimeZoneId) { $updated = $updated->toDateTime(); } - if (!($updated instanceof \DateTimeInterface)) { - throw new \Exception("Unable to get datetime info from updated property of type '".get_class($updated)."'."); + if (!($updated instanceof DateTimeInterface)) { + throw new Exception("Unable to get datetime info from updated property of type '".get_class($updated)."'."); } $cypherFragment->addProperty('updated', $updated); $mongoFragment->addProperty('updated', new UTCDateTime($updated)); diff --git a/src/EventSystem/ElementPropertyChange/EventListener/CreatedElementPropertyChangeEventListener.php b/src/EventSystem/ElementPropertyChange/EventListener/CreatedElementPropertyChangeEventListener.php index 79432e06..70893c54 100644 --- a/src/EventSystem/ElementPropertyChange/EventListener/CreatedElementPropertyChangeEventListener.php +++ b/src/EventSystem/ElementPropertyChange/EventListener/CreatedElementPropertyChangeEventListener.php @@ -3,6 +3,7 @@ namespace App\EventSystem\ElementPropertyChange\EventListener; use App\EventSystem\ElementPropertyChange\Event\ElementPropertyChangeEvent; +use Exception; class CreatedElementPropertyChangeEventListener { @@ -15,6 +16,6 @@ public function onElementPropertyChangeEvent(ElementPropertyChangeEvent $event): if (!array_key_exists('created', $event->getChangedProperties())) { return; } - throw new \Exception("Setting the property 'created' is forbidden."); + throw new Exception("Setting the property 'created' is forbidden."); } } diff --git a/src/EventSystem/ElementPropertyChange/EventListener/IdElementPropertyChangeEventListener.php b/src/EventSystem/ElementPropertyChange/EventListener/IdElementPropertyChangeEventListener.php index 49b7e803..441c2d10 100644 --- a/src/EventSystem/ElementPropertyChange/EventListener/IdElementPropertyChangeEventListener.php +++ b/src/EventSystem/ElementPropertyChange/EventListener/IdElementPropertyChangeEventListener.php @@ -3,6 +3,7 @@ namespace App\EventSystem\ElementPropertyChange\EventListener; use App\EventSystem\ElementPropertyChange\Event\ElementPropertyChangeEvent; +use Exception; class IdElementPropertyChangeEventListener { @@ -15,6 +16,6 @@ public function onElementPropertyChangeEvent(ElementPropertyChangeEvent $event): if (!array_key_exists('id', $event->getChangedProperties())) { return; } - throw new \Exception("Setting the property 'id' is forbidden."); + throw new Exception("Setting the property 'id' is forbidden."); } } diff --git a/src/EventSystem/ElementPropertyChange/EventListener/TokenElementPropertyChangeEventListener.php b/src/EventSystem/ElementPropertyChange/EventListener/TokenElementPropertyChangeEventListener.php index 709bc85b..d7b4779a 100644 --- a/src/EventSystem/ElementPropertyChange/EventListener/TokenElementPropertyChangeEventListener.php +++ b/src/EventSystem/ElementPropertyChange/EventListener/TokenElementPropertyChangeEventListener.php @@ -3,6 +3,7 @@ namespace App\EventSystem\ElementPropertyChange\EventListener; use App\EventSystem\ElementPropertyChange\Event\ElementPropertyChangeEvent; +use Exception; class TokenElementPropertyChangeEventListener { @@ -16,10 +17,10 @@ public function onElementPropertyChangeEvent(ElementPropertyChangeEvent $event): return; } if (array_key_exists('token', $event->getChangedProperties())) { - throw new \Exception("Setting the property 'token' is forbidden."); + throw new Exception("Setting the property 'token' is forbidden."); } if (array_key_exists('_tokenHash', $event->getChangedProperties())) { - throw new \Exception("Setting the property '_tokenHash' is forbidden."); + throw new Exception("Setting the property '_tokenHash' is forbidden."); } } } diff --git a/src/EventSystem/ElementPropertyChange/EventListener/UpdatedElementPropertyChangeEventListener.php b/src/EventSystem/ElementPropertyChange/EventListener/UpdatedElementPropertyChangeEventListener.php index 2ea67fb7..fa3daac2 100644 --- a/src/EventSystem/ElementPropertyChange/EventListener/UpdatedElementPropertyChangeEventListener.php +++ b/src/EventSystem/ElementPropertyChange/EventListener/UpdatedElementPropertyChangeEventListener.php @@ -3,6 +3,7 @@ namespace App\EventSystem\ElementPropertyChange\EventListener; use App\EventSystem\ElementPropertyChange\Event\ElementPropertyChangeEvent; +use Exception; class UpdatedElementPropertyChangeEventListener { @@ -15,6 +16,6 @@ public function onElementPropertyChangeEvent(ElementPropertyChangeEvent $event): if (!array_key_exists('updated', $event->getChangedProperties())) { return; } - throw new \Exception("Setting the property 'updated' is forbidden."); + throw new Exception("Setting the property 'updated' is forbidden."); } } diff --git a/src/EventSystem/ElementPropertyChange/EventListener/UserElementPropertyChangeEventListener.php b/src/EventSystem/ElementPropertyChange/EventListener/UserElementPropertyChangeEventListener.php index 62f383a8..a7933364 100644 --- a/src/EventSystem/ElementPropertyChange/EventListener/UserElementPropertyChangeEventListener.php +++ b/src/EventSystem/ElementPropertyChange/EventListener/UserElementPropertyChangeEventListener.php @@ -4,6 +4,7 @@ use App\EventSystem\ElementPropertyChange\Event\ElementPropertyChangeEvent; use EmberNexusBundle\Service\EmberNexusConfiguration; +use Exception; class UserElementPropertyChangeEventListener { @@ -18,10 +19,10 @@ public function onElementPropertyChangeEvent(ElementPropertyChangeEvent $event): return; } if (array_key_exists('_passwordHash', $event->getChangedProperties())) { - throw new \Exception("Setting the property '_passwordHash' is forbidden."); + throw new Exception("Setting the property '_passwordHash' is forbidden."); } if (array_key_exists($this->emberNexusConfiguration->getRegisterUniqueIdentifier(), $event->getChangedProperties())) { - throw new \Exception(sprintf("Setting the property '%s' is forbidden.", $this->emberNexusConfiguration->getRegisterUniqueIdentifier())); + throw new Exception(sprintf("Setting the property '%s' is forbidden.", $this->emberNexusConfiguration->getRegisterUniqueIdentifier())); } } } diff --git a/src/EventSystem/EntityManager/EventListener/CreatedElementPreWriteEventListener.php b/src/EventSystem/EntityManager/EventListener/CreatedElementPreWriteEventListener.php index 82368f77..b5eec765 100644 --- a/src/EventSystem/EntityManager/EventListener/CreatedElementPreWriteEventListener.php +++ b/src/EventSystem/EntityManager/EventListener/CreatedElementPreWriteEventListener.php @@ -4,6 +4,7 @@ use App\EventSystem\EntityManager\Event\ElementPreCreateEvent; use App\EventSystem\EntityManager\Event\ElementPreMergeEvent; +use DateTime; class CreatedElementPreWriteEventListener { @@ -23,6 +24,6 @@ private function handleEvent(ElementPreCreateEvent|ElementPreMergeEvent $event): if ($element->hasProperty('created')) { return; } - $element->addProperty('created', new \DateTime()); + $element->addProperty('created', new DateTime()); } } diff --git a/src/EventSystem/EntityManager/EventListener/OwnershipChangeEventListener.php b/src/EventSystem/EntityManager/EventListener/OwnershipChangeEventListener.php index 920be509..a48b61d9 100644 --- a/src/EventSystem/EntityManager/EventListener/OwnershipChangeEventListener.php +++ b/src/EventSystem/EntityManager/EventListener/OwnershipChangeEventListener.php @@ -7,6 +7,7 @@ use App\EventSystem\EntityManager\Event\ElementPostDeleteEvent; use App\EventSystem\EntityManager\Event\ElementPostMergeEvent; use App\Type\RabbitMQQueueType; +use Exception; use PhpAmqpLib\Connection\AMQPStreamConnection; use PhpAmqpLib\Message\AMQPMessage; @@ -73,7 +74,7 @@ public function handleOwnershipChange(RelationElementInterface $element): void 'element' => $elementId->toString(), ], JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES); if (!is_string($jsonMessage)) { - throw new \Exception('Internal server exception.'); + throw new Exception('Internal server exception.'); } $message = new AMQPMessage($jsonMessage); $channel->basic_publish($message, '', $queue); diff --git a/src/EventSystem/EntityManager/EventListener/UpdatedElementPreWriteEventListener.php b/src/EventSystem/EntityManager/EventListener/UpdatedElementPreWriteEventListener.php index a759d238..b880efd3 100644 --- a/src/EventSystem/EntityManager/EventListener/UpdatedElementPreWriteEventListener.php +++ b/src/EventSystem/EntityManager/EventListener/UpdatedElementPreWriteEventListener.php @@ -4,6 +4,7 @@ use App\EventSystem\EntityManager\Event\ElementPreCreateEvent; use App\EventSystem\EntityManager\Event\ElementPreMergeEvent; +use DateTime; class UpdatedElementPreWriteEventListener { @@ -23,6 +24,6 @@ private function handleEvent(ElementPreCreateEvent|ElementPreMergeEvent $event): if ($element->hasProperty('updated')) { return; } - $element->addProperty('updated', new \DateTime()); + $element->addProperty('updated', new DateTime()); } } diff --git a/src/EventSystem/Exception/EventListener/ExceptionEventListener.php b/src/EventSystem/Exception/EventListener/ExceptionEventListener.php index 285e8627..678c6ae9 100644 --- a/src/EventSystem/Exception/EventListener/ExceptionEventListener.php +++ b/src/EventSystem/Exception/EventListener/ExceptionEventListener.php @@ -2,9 +2,10 @@ namespace App\EventSystem\Exception\EventListener; -use App\Exception\ExtendedException; -use App\Exception\ServerException; +use App\Exception\ProblemJsonException; +use App\Exception\Server500InternalServerErrorException; use App\Response\ProblemJsonResponse; +use Exception; use Psr\Log\LoggerInterface; use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface; use Symfony\Component\HttpKernel\Event\ExceptionEvent; @@ -28,11 +29,11 @@ public function onKernelException(ExceptionEvent $event): void { $this->logger->error($event->getThrowable()); $originalException = $extendedException = $event->getThrowable(); - if (!($originalException instanceof ExtendedException)) { - $extendedException = new ServerException(detail: 'Other internal exception.'); + if (!($originalException instanceof ProblemJsonException)) { + $extendedException = Server500InternalServerErrorException::createFromTemplate('Other internal exception.'); } /** - * @var ExtendedException $extendedException + * @var ProblemJsonException $extendedException */ $instance = $extendedException->getInstance(); $instanceLink = null; @@ -43,7 +44,7 @@ public function onKernelException(ExceptionEvent $event): void $instance ?? 'unknown' ) ); - } catch (\Exception $e) { + } catch (Exception $e) { } // check if there are configured alternatives for the instance links @@ -68,6 +69,10 @@ public function onKernelException(ExceptionEvent $event): void unset($data['instance']); } + if ('' === $data['detail']) { + unset($data['detail']); + } + if ($this->kernel->isDebug()) { $data['exception'] = [ 'message' => $originalException->getMessage(), diff --git a/src/EventSystem/NormalizedValueToRawValue/EventListener/DateTimeNormalizedValueToRawValueEventListener.php b/src/EventSystem/NormalizedValueToRawValue/EventListener/DateTimeNormalizedValueToRawValueEventListener.php index 8941087c..5558bf25 100644 --- a/src/EventSystem/NormalizedValueToRawValue/EventListener/DateTimeNormalizedValueToRawValueEventListener.php +++ b/src/EventSystem/NormalizedValueToRawValue/EventListener/DateTimeNormalizedValueToRawValueEventListener.php @@ -3,16 +3,18 @@ namespace App\EventSystem\NormalizedValueToRawValue\EventListener; use App\EventSystem\NormalizedValueToRawValue\Event\NormalizedValueToRawValueEvent; +use DateTime; +use DateTimeInterface; class DateTimeNormalizedValueToRawValueEventListener { public function onNormalizedValueToRawValueEvent(NormalizedValueToRawValueEvent $event): void { $normalizedValue = $event->getNormalizedValue(); - if (!($normalizedValue instanceof \DateTimeInterface)) { + if (!($normalizedValue instanceof DateTimeInterface)) { return; } - $event->setRawValue($normalizedValue->format(\DateTime::ATOM)); + $event->setRawValue($normalizedValue->format(DateTime::ATOM)); $event->stopPropagation(); } } diff --git a/src/EventSystem/RawValueToNormalizedValue/EventListener/DateTimeRawValueToNormalizedValueEventListener.php b/src/EventSystem/RawValueToNormalizedValue/EventListener/DateTimeRawValueToNormalizedValueEventListener.php index 9ab8bbc2..6c805f13 100644 --- a/src/EventSystem/RawValueToNormalizedValue/EventListener/DateTimeRawValueToNormalizedValueEventListener.php +++ b/src/EventSystem/RawValueToNormalizedValue/EventListener/DateTimeRawValueToNormalizedValueEventListener.php @@ -3,6 +3,7 @@ namespace App\EventSystem\RawValueToNormalizedValue\EventListener; use App\EventSystem\RawValueToNormalizedValue\Event\RawValueToNormalizedValueEvent; +use DateTime; class DateTimeRawValueToNormalizedValueEventListener { @@ -18,7 +19,7 @@ public function onRawValueToNormalizedValueEvent(RawValueToNormalizedValueEvent ) { return; } - $possibleDate = \DateTime::createFromFormat(\DateTime::ATOM, $rawValue); + $possibleDate = DateTime::createFromFormat(DateTime::ATOM, $rawValue); if (false === $possibleDate) { return; } diff --git a/src/EventSystem/Request/EventListener/ApiKeyCheckOnKernelRequestEventListener.php b/src/EventSystem/Request/EventListener/ApiKeyCheckOnKernelRequestEventListener.php index c138316d..0ed27f5e 100644 --- a/src/EventSystem/Request/EventListener/ApiKeyCheckOnKernelRequestEventListener.php +++ b/src/EventSystem/Request/EventListener/ApiKeyCheckOnKernelRequestEventListener.php @@ -2,7 +2,7 @@ namespace App\EventSystem\Request\EventListener; -use App\Exception\ClientUnauthorizedException; +use App\Exception\Client401UnauthorizedException; use App\Security\AuthProvider; use App\Security\TokenGenerator; use App\Type\UserUuidAndTokenUuidObject; @@ -14,6 +14,8 @@ use Symfony\Component\HttpKernel\Event\RequestEvent; use Syndesi\CypherEntityManager\Type\EntityManager as CypherEntityManager; +use function str_starts_with; + class ApiKeyCheckOnKernelRequestEventListener { public function __construct( @@ -61,7 +63,7 @@ private function getUserUuidAndTokenUuidObjectFromTokenFromCypher(string $token) ); if (0 === count($res)) { - throw new ClientUnauthorizedException('Invalid authorization token'); + throw new Client401UnauthorizedException('Invalid authorization token'); } $userUuid = Uuid::fromString($res->first()->get('user.id')); @@ -108,11 +110,11 @@ private function extractTokenFromRequest(Request $request): string { $tokenParts = explode(' ', $request->headers->get('Authorization') ?? '', 2); if (2 !== count($tokenParts)) { - throw new ClientUnauthorizedException('Invalid authorization token'); + throw new Client401UnauthorizedException('Invalid authorization token'); } $token = $tokenParts[1]; - if (!\str_starts_with($token, 'secret-token:')) { - throw new ClientUnauthorizedException('Invalid authorization token'); + if (!str_starts_with($token, 'secret-token:')) { + throw new Client401UnauthorizedException('Invalid authorization token'); } return $token; diff --git a/src/Exception/ClientException.php b/src/Exception/Client400BadContentException.php old mode 100755 new mode 100644 similarity index 64% rename from src/Exception/ClientException.php rename to src/Exception/Client400BadContentException.php index 8481e6cb..17efd548 --- a/src/Exception/ClientException.php +++ b/src/Exception/Client400BadContentException.php @@ -2,15 +2,17 @@ namespace App\Exception; -class ClientException extends ExtendedException +use Throwable; + +class Client400BadContentException extends ProblemJsonException { public function __construct( string $type, - string $title = 'Generic client error', + string $title = 'Bad content', int $status = 400, string $detail = '', string $instance = null, - \Throwable $previous = null + Throwable $previous = null ) { parent::__construct($type, $title, $status, $detail, $instance, $previous); } diff --git a/src/Exception/Client400ForbiddenPropertyException.php b/src/Exception/Client400ForbiddenPropertyException.php new file mode 100644 index 00000000..1a828fcc --- /dev/null +++ b/src/Exception/Client400ForbiddenPropertyException.php @@ -0,0 +1,19 @@ +type = $type; diff --git a/src/Exception/Server500InternalServerErrorException.php b/src/Exception/Server500InternalServerErrorException.php new file mode 100644 index 00000000..0ee705a2 --- /dev/null +++ b/src/Exception/Server500InternalServerErrorException.php @@ -0,0 +1,19 @@ +urlGenerator->generate( + 'exception-detail', + [ + 'code' => '400', + 'name' => 'bad-content', + ], + UrlGeneratorInterface::ABSOLUTE_URL + ), + detail: sprintf( + "Endpoint expects property '%s' to be %s, got '%s'.", + $propertyName, + $expectedContent, + $realContent + ) + ); + } +} diff --git a/src/Factory/Exception/Client400ForbiddenPropertyExceptionFactory.php b/src/Factory/Exception/Client400ForbiddenPropertyExceptionFactory.php new file mode 100644 index 00000000..98135aa0 --- /dev/null +++ b/src/Factory/Exception/Client400ForbiddenPropertyExceptionFactory.php @@ -0,0 +1,35 @@ +urlGenerator->generate( + 'exception-detail', + [ + 'code' => '400', + 'name' => 'forbidden-property', + ], + UrlGeneratorInterface::ABSOLUTE_URL + ), + detail: sprintf( + "Endpoint does not accept setting the property '%s' in the request.", + $propertyName + ) + ); + } +} diff --git a/src/Factory/Exception/Client400IncompleteMutualDependencyExceptionFactory.php b/src/Factory/Exception/Client400IncompleteMutualDependencyExceptionFactory.php new file mode 100644 index 00000000..a949e872 --- /dev/null +++ b/src/Factory/Exception/Client400IncompleteMutualDependencyExceptionFactory.php @@ -0,0 +1,77 @@ +urlGenerator->generate( + 'exception-detail', + [ + 'code' => '400', + 'name' => 'incomplete-mutual-dependency', + ], + UrlGeneratorInterface::ABSOLUTE_URL + ), + detail: $message + ); + } +} diff --git a/src/Factory/Exception/Client400MissingPropertyExceptionFactory.php b/src/Factory/Exception/Client400MissingPropertyExceptionFactory.php new file mode 100644 index 00000000..18903027 --- /dev/null +++ b/src/Factory/Exception/Client400MissingPropertyExceptionFactory.php @@ -0,0 +1,36 @@ +urlGenerator->generate( + 'exception-detail', + [ + 'code' => '400', + 'name' => 'missing-property', + ], + UrlGeneratorInterface::ABSOLUTE_URL + ), + detail: sprintf( + "Endpoint requires that the request contains property '%s' to be set to %s.", + $propertyName, + $propertyValue + ) + ); + } +} diff --git a/src/Factory/Exception/Client400ReservedIdentifierExceptionFactory.php b/src/Factory/Exception/Client400ReservedIdentifierExceptionFactory.php new file mode 100644 index 00000000..2ebdf24c --- /dev/null +++ b/src/Factory/Exception/Client400ReservedIdentifierExceptionFactory.php @@ -0,0 +1,35 @@ +urlGenerator->generate( + 'exception-detail', + [ + 'code' => '400', + 'name' => 'reserved-identifier', + ], + UrlGeneratorInterface::ABSOLUTE_URL + ), + detail: sprintf( + "The requested identifier '%s' is reserved and can not be used.", + $identifier + ) + ); + } +} diff --git a/src/Factory/Exception/Client401UnauthorizedExceptionFactory.php b/src/Factory/Exception/Client401UnauthorizedExceptionFactory.php new file mode 100644 index 00000000..a9477e2f --- /dev/null +++ b/src/Factory/Exception/Client401UnauthorizedExceptionFactory.php @@ -0,0 +1,28 @@ +urlGenerator->generate( + 'exception-detail', + [ + 'code' => '401', + 'name' => 'unauthorized', + ], + UrlGeneratorInterface::ABSOLUTE_URL + ) + ); + } +} diff --git a/src/Factory/Exception/Client403ForbiddenExceptionFactory.php b/src/Factory/Exception/Client403ForbiddenExceptionFactory.php new file mode 100644 index 00000000..5c903c1f --- /dev/null +++ b/src/Factory/Exception/Client403ForbiddenExceptionFactory.php @@ -0,0 +1,28 @@ +urlGenerator->generate( + 'exception-detail', + [ + 'code' => '403', + 'name' => 'forbidden', + ], + UrlGeneratorInterface::ABSOLUTE_URL + ) + ); + } +} diff --git a/src/Factory/Exception/Client404NotFoundExceptionFactory.php b/src/Factory/Exception/Client404NotFoundExceptionFactory.php new file mode 100644 index 00000000..5c9341ac --- /dev/null +++ b/src/Factory/Exception/Client404NotFoundExceptionFactory.php @@ -0,0 +1,28 @@ +urlGenerator->generate( + 'exception-detail', + [ + 'code' => '404', + 'name' => 'not-found', + ], + UrlGeneratorInterface::ABSOLUTE_URL + ) + ); + } +} diff --git a/src/Factory/Exception/Client405MethodNotAllowedExceptionFactory.php b/src/Factory/Exception/Client405MethodNotAllowedExceptionFactory.php new file mode 100644 index 00000000..1a1ac90c --- /dev/null +++ b/src/Factory/Exception/Client405MethodNotAllowedExceptionFactory.php @@ -0,0 +1,28 @@ +urlGenerator->generate( + 'exception-detail', + [ + 'code' => '405', + 'name' => 'method-not-allowed', + ], + UrlGeneratorInterface::ABSOLUTE_URL + ) + ); + } +} diff --git a/src/Factory/Exception/Client429TooManyRequestsExceptionFactory.php b/src/Factory/Exception/Client429TooManyRequestsExceptionFactory.php new file mode 100644 index 00000000..3c1f7673 --- /dev/null +++ b/src/Factory/Exception/Client429TooManyRequestsExceptionFactory.php @@ -0,0 +1,28 @@ +urlGenerator->generate( + 'exception-detail', + [ + 'code' => '429', + 'name' => 'too-many-requests', + ], + UrlGeneratorInterface::ABSOLUTE_URL + ) + ); + } +} diff --git a/src/Factory/Exception/Server500InternalServerErrorExceptionFactory.php b/src/Factory/Exception/Server500InternalServerErrorExceptionFactory.php new file mode 100644 index 00000000..79c2613e --- /dev/null +++ b/src/Factory/Exception/Server500InternalServerErrorExceptionFactory.php @@ -0,0 +1,39 @@ +bag->get('kernel.environment')) { + $message = $developmentDetail; + } + + return new Server500InternalServerErrorException( + $this->urlGenerator->generate( + 'exception-detail', + [ + 'code' => '500', + 'name' => 'internal-server-error', + ], + UrlGeneratorInterface::ABSOLUTE_URL + ), + detail: $message + ); + } +} diff --git a/src/Factory/Exception/Server500LogicExceptionFactory.php b/src/Factory/Exception/Server500LogicExceptionFactory.php new file mode 100644 index 00000000..93724b66 --- /dev/null +++ b/src/Factory/Exception/Server500LogicExceptionFactory.php @@ -0,0 +1,39 @@ +bag->get('kernel.environment')) { + $message = $developmentDetail; + } + + return new Server500LogicErrorException( + $this->urlGenerator->generate( + 'exception-detail', + [ + 'code' => '500', + 'name' => 'internal-server-error', + ], + UrlGeneratorInterface::ABSOLUTE_URL + ), + detail: $message + ); + } +} diff --git a/src/Factory/Exception/Server501NotImplementedExceptionFactory.php b/src/Factory/Exception/Server501NotImplementedExceptionFactory.php new file mode 100644 index 00000000..3596ccf9 --- /dev/null +++ b/src/Factory/Exception/Server501NotImplementedExceptionFactory.php @@ -0,0 +1,28 @@ +urlGenerator->generate( + 'exception-detail', + [ + 'code' => '501', + 'name' => 'not-implemented', + ], + UrlGeneratorInterface::ABSOLUTE_URL + ) + ); + } +} diff --git a/src/Factory/Exception/Server503ServiceUnavailableExceptionFactory.php b/src/Factory/Exception/Server503ServiceUnavailableExceptionFactory.php new file mode 100644 index 00000000..10d12b16 --- /dev/null +++ b/src/Factory/Exception/Server503ServiceUnavailableExceptionFactory.php @@ -0,0 +1,42 @@ +bag->get('kernel.environment')) { + $message = sprintf( + "Service '%s' is currently unavailable.", + $service + ); + } + + return new Server503ServiceUnavailableException( + $this->urlGenerator->generate( + 'exception-detail', + [ + 'code' => '503', + 'name' => 'service-unavailable', + ], + UrlGeneratorInterface::ABSOLUTE_URL + ), + detail: $message + ); + } +} diff --git a/src/Factory/RabbitMQFactory.php b/src/Factory/RabbitMQFactory.php index 97a92ee0..da61286a 100644 --- a/src/Factory/RabbitMQFactory.php +++ b/src/Factory/RabbitMQFactory.php @@ -3,6 +3,7 @@ namespace App\Factory; use App\Exception\ServerException; +use Exception; use PhpAmqpLib\Connection\AMQPStreamConnection; class RabbitMQFactory @@ -17,7 +18,7 @@ public function createRabbitMQ(): AMQPStreamConnection $parsed = parse_url($this->rabbitMQAuth); if (!is_array($parsed)) { - throw new \Exception('Unable to correctly parse RabbitMQ DSN.'); + throw new Exception('Unable to correctly parse RabbitMQ DSN.'); } if (!array_key_exists('user', $parsed)) { diff --git a/src/Response/TextResponse.php b/src/Response/TextResponse.php new file mode 100644 index 00000000..8694d3ac --- /dev/null +++ b/src/Response/TextResponse.php @@ -0,0 +1,24 @@ + $headers + */ + public function __construct(string $content = '', int $status = 200, array $headers = []) + { + $this->charset = 'UTF-8'; + parent::__construct( + $content, + $status, + [ + 'Content-Type' => 'text/plain; charset=utf-8', + ...$headers, + ] + ); + } +} diff --git a/src/Security/AuthProvider.php b/src/Security/AuthProvider.php index ed9501a5..a10eb571 100755 --- a/src/Security/AuthProvider.php +++ b/src/Security/AuthProvider.php @@ -2,6 +2,7 @@ namespace App\Security; +use LogicException; use Ramsey\Uuid\Rfc4122\UuidV4; use Ramsey\Uuid\UuidInterface; use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface; @@ -17,7 +18,7 @@ public function __construct( ) { $anonymousUserUuid = $this->bag->get('anonymousUserUUID'); if (!is_string($anonymousUserUuid)) { - throw new \LogicException('anonymousUserUUID must be set to a valid UUID'); + throw new LogicException('anonymousUserUUID must be set to a valid UUID'); } $this->userUuid = UuidV4::fromString($anonymousUserUuid); $this->isAnonymous = true; diff --git a/src/Security/TokenGenerator.php b/src/Security/TokenGenerator.php index 07c84c58..7de4f4cf 100755 --- a/src/Security/TokenGenerator.php +++ b/src/Security/TokenGenerator.php @@ -5,6 +5,7 @@ use App\Service\ElementManager; use App\Type\NodeElement; use App\Type\RelationElement; +use DateInterval; use EmberNexusBundle\Service\EmberNexusConfiguration; use Laudis\Neo4j\Databags\Statement; use Ramsey\Uuid\Uuid; @@ -67,7 +68,7 @@ public function createNewToken(UuidInterface $userUuid, string $name = null, int ->setIdentifier($tokenUuid) ->addProperties([ 'hash' => $hash, - 'expirationDate' => (new DateTime())->add(new \DateInterval(sprintf('PT%sS', $lifetimeInSeconds))), + 'expirationDate' => (new DateTime())->add(new DateInterval(sprintf('PT%sS', $lifetimeInSeconds))), 'name' => $name, ]); $this->elementManager->create($tokenNode); diff --git a/src/Service/CollectionService.php b/src/Service/CollectionService.php index 3c97100c..dbca6ced 100755 --- a/src/Service/CollectionService.php +++ b/src/Service/CollectionService.php @@ -4,6 +4,7 @@ use App\Response\CollectionResponse; use EmberNexusBundle\Service\EmberNexusConfiguration; +use LogicException; use Ramsey\Uuid\UuidInterface; use Symfony\Component\HttpFoundation\InputBag; use Symfony\Component\HttpFoundation\RequestStack; @@ -23,7 +24,7 @@ public function getCurrentPage(): int $firstPage = 1; $query = $this->requestStack->getCurrentRequest()?->query; if (!($query instanceof InputBag)) { - throw new \LogicException(); + throw new LogicException(); } if (!$query->has('page')) { return $firstPage; @@ -40,7 +41,7 @@ public function getPageSize(): int { $query = $this->requestStack->getCurrentRequest()?->query; if (!($query instanceof InputBag)) { - throw new \LogicException(); + throw new LogicException(); } if (!$query->has('pageSize')) { return $this->emberNexusConfiguration->getPageSizeDefault(); @@ -68,7 +69,7 @@ public function getPageLink(int $page = null): string { $currentRequest = $this->requestStack->getCurrentRequest(); if (null === $currentRequest) { - throw new \LogicException(); + throw new LogicException(); } $basePath = $currentRequest->getBasePath(); diff --git a/src/Service/ElementManager.php b/src/Service/ElementManager.php index 775a927b..3a14dc4f 100755 --- a/src/Service/ElementManager.php +++ b/src/Service/ElementManager.php @@ -12,6 +12,8 @@ use App\EventSystem\EntityManager\Event\ElementPreMergeEvent; use App\Helper\Neo4jClientHelper; use Laudis\Neo4j\Databags\Statement; +use LogicException; +use OutOfBoundsException; use Psr\EventDispatcher\EventDispatcherInterface; use Ramsey\Uuid\UuidInterface; use Syndesi\CypherEntityManager\Type\EntityManager as CypherEntityManager; @@ -144,7 +146,7 @@ public function getNode(UuidInterface $uuid): ?NodeElementInterface ); try { $cypherFragment = $this->neo4jClientHelper->getNodeFromLaudisNode($res->first()->get('node')); - } catch (\OutOfBoundsException $e) { + } catch (OutOfBoundsException $e) { return null; } $documentFragment = $this->mongoEntityManager->getOneByIdentifier($cypherFragment->getLabels()[0], $uuid->toString()); @@ -173,12 +175,12 @@ public function getRelation(UuidInterface $uuid): ?RelationElementInterface $res->first()->get('startNode'), $res->first()->get('endNode') ); - } catch (\OutOfBoundsException $e) { + } catch (OutOfBoundsException $e) { return null; } $type = $cypherFragment->getType(); if (null === $type) { - throw new \LogicException('Unable to get relationship type'); + throw new LogicException('Unable to get relationship type'); } $documentFragment = $this->mongoEntityManager->getOneByIdentifier($type, $uuid->toString()); diff --git a/src/Service/ElementResponseService.php b/src/Service/ElementResponseService.php index cd2c97cc..104d40ac 100755 --- a/src/Service/ElementResponseService.php +++ b/src/Service/ElementResponseService.php @@ -3,6 +3,7 @@ namespace App\Service; use App\Response\ElementResponse; +use LogicException; use Ramsey\Uuid\UuidInterface; class ElementResponseService @@ -18,7 +19,7 @@ public function buildElementResponseFromUuid( ): ElementResponse { $element = $this->elementManager->getElement($uuid); if (null === $element) { - throw new \LogicException(sprintf("Unable to find element with the id '%s'.", $uuid->toString())); + throw new LogicException(sprintf("Unable to find element with the id '%s'.", $uuid->toString())); } $rawData = $this->elementToRawService->elementToRaw($element); diff --git a/src/Service/RawToElementService.php b/src/Service/RawToElementService.php index 11e4d803..9a33bbdc 100755 --- a/src/Service/RawToElementService.php +++ b/src/Service/RawToElementService.php @@ -7,6 +7,7 @@ use App\EventSystem\RawValueToNormalizedValue\Event\RawValueToNormalizedValueEvent; use App\Type\NodeElement; use App\Type\RelationElement; +use Exception; use Psr\EventDispatcher\EventDispatcherInterface; use Ramsey\Uuid\Uuid; @@ -23,12 +24,12 @@ public function __construct( public function rawToElement(array $rawData): NodeElementInterface|RelationElementInterface { if (!array_key_exists('type', $rawData)) { - throw new \Exception("Unable to find required property 'type' in raw data."); + throw new Exception("Unable to find required property 'type' in raw data."); } $type = $rawData['type']; if (!array_key_exists('id', $rawData)) { - throw new \Exception("Unable to find required property 'id' in raw data."); + throw new Exception("Unable to find required property 'id' in raw data."); } $id = Uuid::fromString($rawData['id']); diff --git a/src/Style/EmberNexusStyle.php b/src/Style/EmberNexusStyle.php index 81c1535e..61ee12c3 100755 --- a/src/Style/EmberNexusStyle.php +++ b/src/Style/EmberNexusStyle.php @@ -3,6 +3,7 @@ namespace App\Style; use App\Console\EmberNexusOutputWrapper; +use Exception; use Symfony\Component\Console\Formatter\OutputFormatterStyle; use Symfony\Component\Console\Helper\Table; use Symfony\Component\Console\Input\InputInterface; @@ -74,7 +75,7 @@ public function title(string $message): void public function success(array|string $message): void { if ($this->isInSection) { - throw new \Exception('Function success() should only be called at end of command, not within sections.'); + throw new Exception('Function success() should only be called at end of command, not within sections.'); } if (is_string($message)) { $message = [$message]; From 594f0907af79ac8db953d38fe5ec4a96f736fc3b Mon Sep 17 00:00:00 2001 From: Syndesi Date: Fri, 25 Aug 2023 22:05:22 +0200 Subject: [PATCH 3/9] WIP rework exception and logging. --- .php-cs-fixer.dist.php | 7 ++++- CHANGELOG.md | 2 ++ docs/_sidebar.md | 3 +- docs/development/exceptions.md | 30 +++++++++++++++++++ .../src/Service/EmberNexusConfiguration.php | 18 ++++++----- ...ElementPropertyChangeEventListenerTest.php | 3 +- ...ElementPropertyChangeEventListenerTest.php | 3 +- ...ElementPropertyChangeEventListenerTest.php | 5 ++-- ...ElementPropertyChangeEventListenerTest.php | 3 +- ...ElementPropertyChangeEventListenerTest.php | 5 ++-- ...alizedValueToRawValueEventListenerTest.php | 3 +- ...alueToNormalizedValueEventListenerTest.php | 10 ++++--- 12 files changed, 70 insertions(+), 22 deletions(-) diff --git a/.php-cs-fixer.dist.php b/.php-cs-fixer.dist.php index 64ed881c..0c0d5298 100755 --- a/.php-cs-fixer.dist.php +++ b/.php-cs-fixer.dist.php @@ -8,7 +8,12 @@ return (new PhpCsFixer\Config()) ->setRules([ '@Symfony' => true, - 'phpdoc_to_comment' => false + 'phpdoc_to_comment' => false, + 'global_namespace_import' => [ + 'import_classes' => true, + 'import_constants' => true, + 'import_functions' => true + ] ]) ->setFinder($finder) ; diff --git a/CHANGELOG.md b/CHANGELOG.md index 642a6ed7..1d494541 100755 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Add CI workflow to check for upstream Alpine updated. ### Changed - Improve documentation. +- Change PHP CS ruleset such that global objects are always imported. +- Rework exception and logging. ## 0.0.24 - 2023-08-21 ### Changed diff --git a/docs/_sidebar.md b/docs/_sidebar.md index 6a448fcb..5ccd647a 100755 --- a/docs/_sidebar.md +++ b/docs/_sidebar.md @@ -37,5 +37,6 @@ - [Backup Commands](/commands/backup) - [Database Commands](/commands/database) - Development - - [Best Practices](/development/best-practices) - [Long Term Plans](/development/long-term-plans) + - [Best Practices](/development/best-practices) + - [Exceptions](/development/exceptions) diff --git a/docs/development/exceptions.md b/docs/development/exceptions.md index e69de29b..13797eb9 100644 --- a/docs/development/exceptions.md +++ b/docs/development/exceptions.md @@ -0,0 +1,30 @@ +# Exceptions + +List of all exceptions: + +- Internal exceptions: Thrown if there is a problem within the API, 5xx error codes +- External exceptions: Thrown if requests from the client are in any way problematic, 4xx error codes. + - `400-bad-request`: Thrown if user supplied data is bad, incomplete, or problematic. + - `401-unauthorized`: Thrown if supplied token is bad, or anonymous user does not exist. + - `404-not-found`: Default error if data does not exist, or user has no permission to read it. + - `405-method-not-allowed`: Returned if user has READ access, but access to current method. + + + +| HTTP Status Code | Type | Title | Example Detail (prod) | Example Detail (dev) | +| ---------------- | ----------------------------------------- | ---------------------------- | ------------------------------------------------------------ | ------------------------------------------------------------ | +| 400 | `/error/400/missing-property` | Missing property | Endpoint requires that the request contains property 'x' to be set to Y. | Endpoint requires that the request contains property 'x' to be set to Y. | +| 400 | `/error/400/forbidden-property` | Forbidden Property | Endpoint does not accept setting the property 'x' in the request. | Endpoint does not accept setting the property 'x' in the request. | +| 400 | `/error/400/incomplete-mutual-dependency` | Incomplete mutual dependency | Endpoint has mutual dependency on properties 'x' and 'y'. While property 'x' is set, property 'y' is missing. | Endpoint has mutual dependency on properties 'x' and 'y'. While property 'x' is set, property 'y' is missing. | +| 400 | `/error/400/reserved-identifier` | Reserved identifier | The requested identifier 'x' is reserved and can not be used. | The requested identifier 'x' is reserved and can not be used. | +| 400 | `/error/400/bad-content` | Bad content | Endpoint expects property 'x' to be Y, got 'z'. | Endpoint expects property 'x' to be Y, got 'z'. | +| 401 | `/error/401/unauthorized` | Unauthorized | Request does not contain valid token. | Request does not contain valid token. | +| 404 | `/error/404/not-found` | Not found | Requested element was not found. | Requested element was not found. | +| 405 | `/error/405/method-not-allowed` | Method not allowed | Endpoint does not support requested method, or you do not have sufficient permissions. | Endpoint does not support requested method, or you do not have sufficient permissions. | +| 429 | `/error/429/too-many-requests` | Too many requests | You have sent too many requests, please slow down. | You have sent too many requests, please slow down. | +| 500 | `/error/500/internal-server-error` | Internal server error | Internal server error, see log. | 'error message'. | +| 501 | `/error/501/not-implemented` | Not implemented | Endpoint is currently not implemented. | Endpoint is currently not implemented. | +| 503 | `/error/503/service-unavailable` | Service unavailable | The service itself or an internal component is currently unavailable. | Service 'x' is currently unavailable. | +| | | | | | +| | | | | | + diff --git a/lib/EmberNexusBundle/src/Service/EmberNexusConfiguration.php b/lib/EmberNexusBundle/src/Service/EmberNexusConfiguration.php index 9f6b9e78..8023d7f0 100644 --- a/lib/EmberNexusBundle/src/Service/EmberNexusConfiguration.php +++ b/lib/EmberNexusBundle/src/Service/EmberNexusConfiguration.php @@ -2,6 +2,8 @@ namespace EmberNexusBundle\Service; +use Exception; + class EmberNexusConfiguration { public const PAGE_SIZE = 'pageSize'; @@ -43,7 +45,7 @@ private static function getValueFromConfig(array $configuration, array $keyParts foreach ($keyParts as $i => $keyPart) { $currentKeyParts[] = $keyPart; if (!array_key_exists($keyPart, $configuration)) { - throw new \Exception(sprintf("Configuration must contain key '%s'.", implode('.', $currentKeyParts))); + throw new Exception(sprintf("Configuration must contain key '%s'.", implode('.', $currentKeyParts))); } $configuration = $configuration[$keyPart]; } @@ -78,13 +80,13 @@ public static function createFromConfiguration(array $configuration): self )); if ($emberNexusConfiguration->getPageSizeMax() < $emberNexusConfiguration->getPageSizeMin()) { - throw new \Exception('pagesize max must be smaller or equal to pagesize min.'); + throw new Exception('pagesize max must be smaller or equal to pagesize min.'); } if ($emberNexusConfiguration->getPageSizeDefault() < $emberNexusConfiguration->getPageSizeMin()) { - throw new \Exception('default page size must be at least as big as min pagesize'); + throw new Exception('default page size must be at least as big as min pagesize'); } if ($emberNexusConfiguration->getPageSizeMax() < $emberNexusConfiguration->getPageSizeDefault()) { - throw new \Exception('default page size must be equal or less than max page size.'); + throw new Exception('default page size must be equal or less than max page size.'); } $emberNexusConfiguration->setRegisterEnabled((bool) self::getValueFromConfig( @@ -164,14 +166,14 @@ public static function createFromConfiguration(array $configuration): self if (false !== $emberNexusConfiguration->getTokenMaxLifetimeInSeconds()) { if ($emberNexusConfiguration->getTokenMaxLifetimeInSeconds() < $emberNexusConfiguration->getTokenMinLifetimeInSeconds()) { - throw new \Exception('token max lifetime must be longer than min lifetime.'); + throw new Exception('token max lifetime must be longer than min lifetime.'); } if ($emberNexusConfiguration->getTokenDefaultLifetimeInSeconds() > $emberNexusConfiguration->getTokenMaxLifetimeInSeconds()) { - throw new \Exception('Token default lifetime must by shorter or equal to max lifetime.'); + throw new Exception('Token default lifetime must by shorter or equal to max lifetime.'); } } if ($emberNexusConfiguration->getTokenDefaultLifetimeInSeconds() < $emberNexusConfiguration->getTokenMinLifetimeInSeconds()) { - throw new \Exception('token default lifetime must be equal or longer to min lifetime.'); + throw new Exception('token default lifetime must be equal or longer to min lifetime.'); } return $emberNexusConfiguration; @@ -233,7 +235,7 @@ public function getRegisterUniqueIdentifier(): string public function setRegisterUniqueIdentifier(string $registerUniqueIdentifier): EmberNexusConfiguration { if (0 === strlen($registerUniqueIdentifier)) { - throw new \Exception('Unique identifier can not be an empty string.'); + throw new Exception('Unique identifier can not be an empty string.'); } $this->registerUniqueIdentifier = $registerUniqueIdentifier; diff --git a/tests/UnitTests/EventSystem/ElementPropertyChange/EventListener/CreatedElementPropertyChangeEventListenerTest.php b/tests/UnitTests/EventSystem/ElementPropertyChange/EventListener/CreatedElementPropertyChangeEventListenerTest.php index 50ed29b3..9f8ac11f 100644 --- a/tests/UnitTests/EventSystem/ElementPropertyChange/EventListener/CreatedElementPropertyChangeEventListenerTest.php +++ b/tests/UnitTests/EventSystem/ElementPropertyChange/EventListener/CreatedElementPropertyChangeEventListenerTest.php @@ -4,6 +4,7 @@ use App\EventSystem\ElementPropertyChange\Event\ElementPropertyChangeEvent; use App\EventSystem\ElementPropertyChange\EventListener\CreatedElementPropertyChangeEventListener; +use Exception; use PHPUnit\Framework\TestCase; class CreatedElementPropertyChangeEventListenerTest extends TestCase @@ -23,7 +24,7 @@ public function testElementWithCreatedPropertyTriggersException(): void } $event = new ElementPropertyChangeEvent('Test', null, ['created' => true]); $eventListener = new CreatedElementPropertyChangeEventListener(); - $this->expectException(\Exception::class); + $this->expectException(Exception::class); $eventListener->onElementPropertyChangeEvent($event); } } diff --git a/tests/UnitTests/EventSystem/ElementPropertyChange/EventListener/IdElementPropertyChangeEventListenerTest.php b/tests/UnitTests/EventSystem/ElementPropertyChange/EventListener/IdElementPropertyChangeEventListenerTest.php index 55a988c4..de04f86f 100644 --- a/tests/UnitTests/EventSystem/ElementPropertyChange/EventListener/IdElementPropertyChangeEventListenerTest.php +++ b/tests/UnitTests/EventSystem/ElementPropertyChange/EventListener/IdElementPropertyChangeEventListenerTest.php @@ -4,6 +4,7 @@ use App\EventSystem\ElementPropertyChange\Event\ElementPropertyChangeEvent; use App\EventSystem\ElementPropertyChange\EventListener\IdElementPropertyChangeEventListener; +use Exception; use PHPUnit\Framework\TestCase; class IdElementPropertyChangeEventListenerTest extends TestCase @@ -23,7 +24,7 @@ public function testElementWithIdPropertyTriggersException(): void } $event = new ElementPropertyChangeEvent('Test', null, ['id' => true]); $eventListener = new IdElementPropertyChangeEventListener(); - $this->expectException(\Exception::class); + $this->expectException(Exception::class); $eventListener->onElementPropertyChangeEvent($event); } } diff --git a/tests/UnitTests/EventSystem/ElementPropertyChange/EventListener/TokenElementPropertyChangeEventListenerTest.php b/tests/UnitTests/EventSystem/ElementPropertyChange/EventListener/TokenElementPropertyChangeEventListenerTest.php index bd478f70..aca6fca5 100644 --- a/tests/UnitTests/EventSystem/ElementPropertyChange/EventListener/TokenElementPropertyChangeEventListenerTest.php +++ b/tests/UnitTests/EventSystem/ElementPropertyChange/EventListener/TokenElementPropertyChangeEventListenerTest.php @@ -4,6 +4,7 @@ use App\EventSystem\ElementPropertyChange\Event\ElementPropertyChangeEvent; use App\EventSystem\ElementPropertyChange\EventListener\TokenElementPropertyChangeEventListener; +use Exception; use PHPUnit\Framework\TestCase; class TokenElementPropertyChangeEventListenerTest extends TestCase @@ -31,7 +32,7 @@ public function testTokenWithTokenPropertyTriggersException(): void } $event = new ElementPropertyChangeEvent('Token', null, ['token' => true]); $eventListener = new TokenElementPropertyChangeEventListener(); - $this->expectException(\Exception::class); + $this->expectException(Exception::class); $eventListener->onElementPropertyChangeEvent($event); } @@ -42,7 +43,7 @@ public function testTokenWithTokenHashPropertyTriggersException(): void } $event = new ElementPropertyChangeEvent('Token', null, ['_tokenHash' => true]); $eventListener = new TokenElementPropertyChangeEventListener(); - $this->expectException(\Exception::class); + $this->expectException(Exception::class); $eventListener->onElementPropertyChangeEvent($event); } } diff --git a/tests/UnitTests/EventSystem/ElementPropertyChange/EventListener/UpdatedElementPropertyChangeEventListenerTest.php b/tests/UnitTests/EventSystem/ElementPropertyChange/EventListener/UpdatedElementPropertyChangeEventListenerTest.php index 7ac6da68..34dd9c9b 100644 --- a/tests/UnitTests/EventSystem/ElementPropertyChange/EventListener/UpdatedElementPropertyChangeEventListenerTest.php +++ b/tests/UnitTests/EventSystem/ElementPropertyChange/EventListener/UpdatedElementPropertyChangeEventListenerTest.php @@ -4,6 +4,7 @@ use App\EventSystem\ElementPropertyChange\Event\ElementPropertyChangeEvent; use App\EventSystem\ElementPropertyChange\EventListener\UpdatedElementPropertyChangeEventListener; +use Exception; use PHPUnit\Framework\TestCase; class UpdatedElementPropertyChangeEventListenerTest extends TestCase @@ -23,7 +24,7 @@ public function testElementWithUpdatedPropertyTriggersException(): void } $event = new ElementPropertyChangeEvent('Test', null, ['updated' => true]); $eventListener = new UpdatedElementPropertyChangeEventListener(); - $this->expectException(\Exception::class); + $this->expectException(Exception::class); $eventListener->onElementPropertyChangeEvent($event); } } diff --git a/tests/UnitTests/EventSystem/ElementPropertyChange/EventListener/UserElementPropertyChangeEventListenerTest.php b/tests/UnitTests/EventSystem/ElementPropertyChange/EventListener/UserElementPropertyChangeEventListenerTest.php index fd7e53ab..3c605e4b 100644 --- a/tests/UnitTests/EventSystem/ElementPropertyChange/EventListener/UserElementPropertyChangeEventListenerTest.php +++ b/tests/UnitTests/EventSystem/ElementPropertyChange/EventListener/UserElementPropertyChangeEventListenerTest.php @@ -5,6 +5,7 @@ use App\EventSystem\ElementPropertyChange\Event\ElementPropertyChangeEvent; use App\EventSystem\ElementPropertyChange\EventListener\UserElementPropertyChangeEventListener; use EmberNexusBundle\Service\EmberNexusConfiguration; +use Exception; use PHPUnit\Framework\TestCase; use Prophecy\PhpUnit\ProphecyTrait; @@ -41,7 +42,7 @@ public function testUserWithPasswordHashPropertyTriggersException(): void $emberNexusConfiguration->getRegisterUniqueIdentifier()->willReturn('email'); $event = new ElementPropertyChangeEvent('User', null, ['_passwordHash' => true]); $eventListener = new UserElementPropertyChangeEventListener($emberNexusConfiguration->reveal()); - $this->expectException(\Exception::class); + $this->expectException(Exception::class); $eventListener->onElementPropertyChangeEvent($event); } @@ -54,7 +55,7 @@ public function testUserWithUniqueIdentifyingPropertyTriggersException(): void $emberNexusConfiguration->getRegisterUniqueIdentifier()->willReturn('email'); $event = new ElementPropertyChangeEvent('User', null, ['email' => true]); $eventListener = new UserElementPropertyChangeEventListener($emberNexusConfiguration->reveal()); - $this->expectException(\Exception::class); + $this->expectException(Exception::class); $eventListener->onElementPropertyChangeEvent($event); } } diff --git a/tests/UnitTests/EventSystem/NormalizedValueToRawValue/EventListener/DateTimeNormalizedValueToRawValueEventListenerTest.php b/tests/UnitTests/EventSystem/NormalizedValueToRawValue/EventListener/DateTimeNormalizedValueToRawValueEventListenerTest.php index aa92c6cf..ace85379 100644 --- a/tests/UnitTests/EventSystem/NormalizedValueToRawValue/EventListener/DateTimeNormalizedValueToRawValueEventListenerTest.php +++ b/tests/UnitTests/EventSystem/NormalizedValueToRawValue/EventListener/DateTimeNormalizedValueToRawValueEventListenerTest.php @@ -4,6 +4,7 @@ use App\EventSystem\NormalizedValueToRawValue\Event\NormalizedValueToRawValueEvent; use App\EventSystem\NormalizedValueToRawValue\EventListener\DateTimeNormalizedValueToRawValueEventListener; +use DateTime; use PHPUnit\Framework\TestCase; class DateTimeNormalizedValueToRawValueEventListenerTest extends TestCase @@ -24,7 +25,7 @@ public function testNonDatetimeValuesAreIgnored(): void public function testDatetimeValuesAreDenormalized(): void { $eventListener = new DateTimeNormalizedValueToRawValueEventListener(); - $event = new NormalizedValueToRawValueEvent(\DateTime::createFromFormat(\DateTime::ATOM, '2005-08-15T15:52:01+00:00')); + $event = new NormalizedValueToRawValueEvent(DateTime::createFromFormat(DateTime::ATOM, '2005-08-15T15:52:01+00:00')); $eventListener->onNormalizedValueToRawValueEvent($event); $this->assertTrue($event->isPropagationStopped()); $rawValue = $event->getRawValue(); diff --git a/tests/UnitTests/EventSystem/RawValueToNormalizedValue/EventListener/DateTimeRawValueToNormalizedValueEventListenerTest.php b/tests/UnitTests/EventSystem/RawValueToNormalizedValue/EventListener/DateTimeRawValueToNormalizedValueEventListenerTest.php index 01c3646b..31c55370 100644 --- a/tests/UnitTests/EventSystem/RawValueToNormalizedValue/EventListener/DateTimeRawValueToNormalizedValueEventListenerTest.php +++ b/tests/UnitTests/EventSystem/RawValueToNormalizedValue/EventListener/DateTimeRawValueToNormalizedValueEventListenerTest.php @@ -4,6 +4,8 @@ use App\EventSystem\RawValueToNormalizedValue\Event\RawValueToNormalizedValueEvent; use App\EventSystem\RawValueToNormalizedValue\EventListener\DateTimeRawValueToNormalizedValueEventListener; +use DateTime; +use DateTimeInterface; use PHPUnit\Framework\TestCase; class DateTimeRawValueToNormalizedValueEventListenerTest extends TestCase @@ -67,11 +69,11 @@ public function testDateStringValuesAreNormalized(): void $eventListener->onRawValueToNormalizedValueEvent($event); $this->assertTrue($event->isPropagationStopped()); $normalizedValue = $event->getNormalizedValue(); - $this->assertInstanceOf(\DateTimeInterface::class, $normalizedValue); + $this->assertInstanceOf(DateTimeInterface::class, $normalizedValue); /** * @var $normalizedValue \DateTimeInterface */ - $this->assertSame('2005-08-15T15:52:01+00:00', $normalizedValue->format(\DateTime::ATOM)); + $this->assertSame('2005-08-15T15:52:01+00:00', $normalizedValue->format(DateTime::ATOM)); } public function testShortDateStringValuesAreNormalized(): void @@ -81,10 +83,10 @@ public function testShortDateStringValuesAreNormalized(): void $eventListener->onRawValueToNormalizedValueEvent($event); $this->assertTrue($event->isPropagationStopped()); $normalizedValue = $event->getNormalizedValue(); - $this->assertInstanceOf(\DateTimeInterface::class, $normalizedValue); + $this->assertInstanceOf(DateTimeInterface::class, $normalizedValue); /** * @var $normalizedValue \DateTimeInterface */ - $this->assertSame('0001-08-15T15:52:01+00:00', $normalizedValue->format(\DateTime::ATOM)); + $this->assertSame('0001-08-15T15:52:01+00:00', $normalizedValue->format(DateTime::ATOM)); } } From e1cffac0bfb3e878cc45445de3eeaaa3aa67f8b4 Mon Sep 17 00:00:00 2001 From: Syndesi Date: Fri, 25 Aug 2023 22:53:06 +0200 Subject: [PATCH 4/9] WIP rework exception and logging. --- .../Element/PostIndexController.php | 6 ++ ...ropertyElementFragmentizeEventListener.php | 9 +-- ...ropertyElementFragmentizeEventListener.php | 9 +-- .../EventListener/ExceptionEventListener.php | 7 ++- ...mpleteMutualDependencyExceptionFactory.php | 8 +-- src/Factory/RabbitMQFactory.php | 20 +++---- tests/FeatureTests/BaseRequestTestCase.php | 7 ++- .../_01_01_NoConnectionTest.php | 28 ++++++---- .../_01_02_NoRelevantConnectionTest.php | 28 ++++++---- ...itherStartOrEndNodeOfRelationshipsTest.php | 56 +++++++++++-------- 10 files changed, 103 insertions(+), 75 deletions(-) diff --git a/src/Controller/Element/PostIndexController.php b/src/Controller/Element/PostIndexController.php index ebc04370..dcb6ac31 100644 --- a/src/Controller/Element/PostIndexController.php +++ b/src/Controller/Element/PostIndexController.php @@ -115,6 +115,9 @@ public function postIndex(Request $request): Response private function createNode(string $type, UuidInterface $nodeId, array $data): Response { $userId = $this->authProvider->getUserUuid(); + if (!$userId) { + throw $this->client401UnauthorizedExceptionFactory->createFromTemplate(); + } $newNode = (new NodeElement()) ->setIdentifier($nodeId) @@ -155,6 +158,9 @@ private function createNode(string $type, UuidInterface $nodeId, array $data): R private function createRelation(string $type, UuidInterface $relationId, UuidInterface $startId, UuidInterface $endId, array $data): Response { $userId = $this->authProvider->getUserUuid(); + if (!$userId) { + throw $this->client401UnauthorizedExceptionFactory->createFromTemplate(); + } if (!$this->accessChecker->hasAccessToElement($userId, $startId, AccessType::CREATE)) { throw $this->client404NotFoundExceptionFactory->createFromTemplate(); diff --git a/src/EventSystem/ElementFragmentize/EventListener/CreatedPropertyElementFragmentizeEventListener.php b/src/EventSystem/ElementFragmentize/EventListener/CreatedPropertyElementFragmentizeEventListener.php index 056876a4..e229d5b7 100644 --- a/src/EventSystem/ElementFragmentize/EventListener/CreatedPropertyElementFragmentizeEventListener.php +++ b/src/EventSystem/ElementFragmentize/EventListener/CreatedPropertyElementFragmentizeEventListener.php @@ -4,7 +4,7 @@ use App\EventSystem\ElementFragmentize\Event\NodeElementFragmentizeEvent; use App\EventSystem\ElementFragmentize\Event\RelationElementFragmentizeEvent; -use App\Exception\ServerException; +use App\Factory\Exception\Server500InternalServerErrorExceptionFactory; use DateTimeInterface; use Exception; use Laudis\Neo4j\Types\DateTimeZoneId; @@ -12,8 +12,9 @@ class CreatedPropertyElementFragmentizeEventListener { - public function __construct() - { + public function __construct( + private Server500InternalServerErrorExceptionFactory $server500InternalServerErrorExceptionFactory + ) { } public function onNodeElementFragmentizeEvent(NodeElementFragmentizeEvent $event): void @@ -37,7 +38,7 @@ private function handleEvent(NodeElementFragmentizeEvent|RelationElementFragment $element = $event->getRelationElement(); } if (!$element->hasProperty('created')) { - throw new ServerException(detail: 'Server must set created property before persisting element'); + throw $this->server500InternalServerErrorExceptionFactory->createFromTemplate('Server must set created property before persisting element'); } $created = $element->getProperty('created'); if ($created instanceof DateTimeZoneId) { diff --git a/src/EventSystem/ElementFragmentize/EventListener/UpdatedPropertyElementFragmentizeEventListener.php b/src/EventSystem/ElementFragmentize/EventListener/UpdatedPropertyElementFragmentizeEventListener.php index 42fd14f8..ed4c4aa6 100644 --- a/src/EventSystem/ElementFragmentize/EventListener/UpdatedPropertyElementFragmentizeEventListener.php +++ b/src/EventSystem/ElementFragmentize/EventListener/UpdatedPropertyElementFragmentizeEventListener.php @@ -4,7 +4,7 @@ use App\EventSystem\ElementFragmentize\Event\NodeElementFragmentizeEvent; use App\EventSystem\ElementFragmentize\Event\RelationElementFragmentizeEvent; -use App\Exception\ServerException; +use App\Factory\Exception\Server500InternalServerErrorExceptionFactory; use DateTimeInterface; use Exception; use Laudis\Neo4j\Types\DateTimeZoneId; @@ -12,8 +12,9 @@ class UpdatedPropertyElementFragmentizeEventListener { - public function __construct() - { + public function __construct( + private Server500InternalServerErrorExceptionFactory $server500InternalServerErrorExceptionFactory + ) { } public function onNodeElementFragmentizeEvent(NodeElementFragmentizeEvent $event): void @@ -37,7 +38,7 @@ private function handleEvent(NodeElementFragmentizeEvent|RelationElementFragment $element = $event->getRelationElement(); } if (!$element->hasProperty('updated')) { - throw new ServerException(detail: 'Server must set updated property before persisting element'); + throw $this->server500InternalServerErrorExceptionFactory->createFromTemplate('Server must set updated property before persisting element'); } $updated = $element->getProperty('updated'); if ($updated instanceof DateTimeZoneId) { diff --git a/src/EventSystem/Exception/EventListener/ExceptionEventListener.php b/src/EventSystem/Exception/EventListener/ExceptionEventListener.php index 678c6ae9..425af899 100644 --- a/src/EventSystem/Exception/EventListener/ExceptionEventListener.php +++ b/src/EventSystem/Exception/EventListener/ExceptionEventListener.php @@ -3,7 +3,7 @@ namespace App\EventSystem\Exception\EventListener; use App\Exception\ProblemJsonException; -use App\Exception\Server500InternalServerErrorException; +use App\Factory\Exception\Server500InternalServerErrorExceptionFactory; use App\Response\ProblemJsonResponse; use Exception; use Psr\Log\LoggerInterface; @@ -18,7 +18,8 @@ public function __construct( private UrlGeneratorInterface $urlGenerator, private KernelInterface $kernel, private ParameterBagInterface $bag, - private LoggerInterface $logger + private LoggerInterface $logger, + private Server500InternalServerErrorExceptionFactory $server500InternalServerErrorExceptionFactory ) { } @@ -30,7 +31,7 @@ public function onKernelException(ExceptionEvent $event): void $this->logger->error($event->getThrowable()); $originalException = $extendedException = $event->getThrowable(); if (!($originalException instanceof ProblemJsonException)) { - $extendedException = Server500InternalServerErrorException::createFromTemplate('Other internal exception.'); + $extendedException = $this->server500InternalServerErrorExceptionFactory->createFromTemplate('Other internal exception.'); } /** * @var ProblemJsonException $extendedException diff --git a/src/Factory/Exception/Client400IncompleteMutualDependencyExceptionFactory.php b/src/Factory/Exception/Client400IncompleteMutualDependencyExceptionFactory.php index a949e872..d8453964 100644 --- a/src/Factory/Exception/Client400IncompleteMutualDependencyExceptionFactory.php +++ b/src/Factory/Exception/Client400IncompleteMutualDependencyExceptionFactory.php @@ -3,13 +3,13 @@ namespace App\Factory\Exception; use App\Exception\Client400IncompleteMutualDependencyException; -use App\Exception\Server500LogicException; use Symfony\Component\Routing\Generator\UrlGeneratorInterface; class Client400IncompleteMutualDependencyExceptionFactory { public function __construct( - private UrlGeneratorInterface $urlGenerator + private UrlGeneratorInterface $urlGenerator, + private Server500LogicExceptionFactory $server500LogicExceptionFactory ) { } @@ -23,7 +23,7 @@ public function __construct( public function createFromTemplate(array $properties, array $setProperties, array $missingProperties): Client400IncompleteMutualDependencyException { if (count($properties) < 2) { - throw Server500LogicException::createFromTemplate('Mutual dependency requires at least two properties.'); + throw $this->server500LogicExceptionFactory->createFromTemplate('Mutual dependency requires at least two properties.'); } $message = sprintf( @@ -48,7 +48,7 @@ public function createFromTemplate(array $properties, array $setProperties, arra } if (0 === count($missingProperties)) { - throw Server500LogicException::createFromTemplate('At least one missing property is required.'); + throw $this->server500LogicExceptionFactory->createFromTemplate('At least one missing property is required.'); } elseif (1 === count($missingProperties)) { $message .= sprintf( " property '%s' is missing.", diff --git a/src/Factory/RabbitMQFactory.php b/src/Factory/RabbitMQFactory.php index da61286a..818541e4 100644 --- a/src/Factory/RabbitMQFactory.php +++ b/src/Factory/RabbitMQFactory.php @@ -2,14 +2,14 @@ namespace App\Factory; -use App\Exception\ServerException; -use Exception; +use App\Factory\Exception\Server500LogicExceptionFactory; use PhpAmqpLib\Connection\AMQPStreamConnection; class RabbitMQFactory { public function __construct( - private string $rabbitMQAuth + private string $rabbitMQAuth, + private Server500LogicExceptionFactory $server500LogicExceptionFactory ) { } @@ -18,31 +18,31 @@ public function createRabbitMQ(): AMQPStreamConnection $parsed = parse_url($this->rabbitMQAuth); if (!is_array($parsed)) { - throw new Exception('Unable to correctly parse RabbitMQ DSN.'); + throw $this->server500LogicExceptionFactory->createFromTemplate('Unable to correctly parse RabbitMQ DSN.'); } if (!array_key_exists('user', $parsed)) { - throw new ServerException(detail: 'RabbitMQ DSN requires user.'); + throw $this->server500LogicExceptionFactory->createFromTemplate('RabbitMQ DSN requires user.'); } $user = $parsed['user']; if (!$user) { - throw new ServerException(detail: 'RabbitMQ DSN requires user.'); + throw $this->server500LogicExceptionFactory->createFromTemplate('RabbitMQ DSN requires user.'); } if (!array_key_exists('pass', $parsed)) { - throw new ServerException(detail: 'RabbitMQ DSN requires password.'); + throw $this->server500LogicExceptionFactory->createFromTemplate('RabbitMQ DSN requires password.'); } $pass = $parsed['pass']; if (!$pass) { - throw new ServerException(detail: 'RabbitMQ DSN requires password.'); + throw $this->server500LogicExceptionFactory->createFromTemplate('RabbitMQ DSN requires password.'); } if (!array_key_exists('host', $parsed)) { - throw new ServerException(detail: 'RabbitMQ DSN requires host.'); + throw $this->server500LogicExceptionFactory->createFromTemplate('RabbitMQ DSN requires host.'); } $host = $parsed['host']; if (!$host) { - throw new ServerException(detail: 'RabbitMQ DSN requires host.'); + throw $this->server500LogicExceptionFactory->createFromTemplate('RabbitMQ DSN requires host.'); } return new AMQPStreamConnection( diff --git a/tests/FeatureTests/BaseRequestTestCase.php b/tests/FeatureTests/BaseRequestTestCase.php index ee691f0a..4c092e0e 100644 --- a/tests/FeatureTests/BaseRequestTestCase.php +++ b/tests/FeatureTests/BaseRequestTestCase.php @@ -219,9 +219,12 @@ public function assertIsProblemResponse(ResponseInterface $response, int $status $body = \Safe\json_decode((string) $response->getBody(), true); $this->assertArrayHasKey('type', $body); + $this->assertStringStartsWith('http', $body['type']); $this->assertArrayHasKey('title', $body); - $this->assertArrayHasKey('detail', $body); - $this->assertArrayHasKey('type', $body); + if (array_key_exists('detail', $body)) { + $this->assertNotEmpty($body['detail']); + } + $this->assertArrayHasKey('status', $body); $this->assertSame($status, $body['status']); } diff --git a/tests/FeatureTests/Security/Scenario01BasicNegativeTests/_01_01_NoConnectionTest.php b/tests/FeatureTests/Security/Scenario01BasicNegativeTests/_01_01_NoConnectionTest.php index 453a40ee..ac7af7de 100644 --- a/tests/FeatureTests/Security/Scenario01BasicNegativeTests/_01_01_NoConnectionTest.php +++ b/tests/FeatureTests/Security/Scenario01BasicNegativeTests/_01_01_NoConnectionTest.php @@ -126,11 +126,13 @@ public function test1010208(): void /** * @description test 1-01-02-20 + * + * @todo refactor in v0.2.0 with actual request required */ public function test1010220(): void { $response = $this->runGetRequest(sprintf('/%s/file', self::DATA), self::TOKEN); - $this->assertIsProblemResponse($response, 404); + $this->assertIsProblemResponse($response, 501); } /** @@ -150,7 +152,7 @@ public function test1010221(): void ], ] ); - $this->assertIsProblemResponse($response, 404); + $this->assertIsProblemResponse($response, 501); } /** @@ -161,7 +163,7 @@ public function test1010221(): void public function test1010222(): void { $response = $this->runPutRequest(sprintf('/%s/file', self::DATA), self::TOKEN, []); - $this->assertIsProblemResponse($response, 404); + $this->assertIsProblemResponse($response, 501); } /** @@ -172,16 +174,18 @@ public function test1010222(): void public function test1010223(): void { $response = $this->runPatchRequest(sprintf('/%s/file', self::DATA), self::TOKEN, []); - $this->assertIsProblemResponse($response, 404); + $this->assertIsProblemResponse($response, 501); } /** * @description test 1-01-02-24 + * + * @todo refactor in v0.2.0 with actual request required */ public function test1010224(): void { $response = $this->runDeleteRequest(sprintf('/%s/file', self::DATA), self::TOKEN); - $this->assertIsProblemResponse($response, 404); + $this->assertIsProblemResponse($response, 501); } /** @@ -192,7 +196,7 @@ public function test1010224(): void public function test1010230(): void { $response = $this->runCopyRequest(sprintf('/%s', self::DATA), self::TOKEN); - $this->assertIsProblemResponse($response, 404); + $this->assertIsProblemResponse($response, 501); } /** @@ -203,7 +207,7 @@ public function test1010230(): void public function test1010231(): void { $response = $this->runLockRequest(sprintf('/%s', self::DATA), self::TOKEN); - $this->assertIsProblemResponse($response, 404); + $this->assertIsProblemResponse($response, 501); } /** @@ -214,7 +218,7 @@ public function test1010231(): void public function test1010232(): void { $response = $this->runUnlockRequest(sprintf('/%s', self::DATA), self::TOKEN); - $this->assertIsProblemResponse($response, 404); + $this->assertIsProblemResponse($response, 501); } /** @@ -225,7 +229,7 @@ public function test1010232(): void public function test1010233(): void { $response = $this->runMkcolRequest(sprintf('/%s', self::DATA), self::TOKEN); - $this->assertIsProblemResponse($response, 404); + $this->assertIsProblemResponse($response, 501); } /** @@ -236,7 +240,7 @@ public function test1010233(): void public function test1010234(): void { $response = $this->runMoveRequest(sprintf('/%s', self::DATA), self::TOKEN); - $this->assertIsProblemResponse($response, 404); + $this->assertIsProblemResponse($response, 501); } /** @@ -247,7 +251,7 @@ public function test1010234(): void public function test1010235(): void { $response = $this->runPropfindRequest(sprintf('/%s', self::DATA), self::TOKEN); - $this->assertIsProblemResponse($response, 404); + $this->assertIsProblemResponse($response, 501); } /** @@ -258,6 +262,6 @@ public function test1010235(): void public function test1010236(): void { $response = $this->runProppatchRequest(sprintf('/%s', self::DATA), self::TOKEN); - $this->assertIsProblemResponse($response, 404); + $this->assertIsProblemResponse($response, 501); } } diff --git a/tests/FeatureTests/Security/Scenario01BasicNegativeTests/_01_02_NoRelevantConnectionTest.php b/tests/FeatureTests/Security/Scenario01BasicNegativeTests/_01_02_NoRelevantConnectionTest.php index 77bdc0df..4fb256c1 100644 --- a/tests/FeatureTests/Security/Scenario01BasicNegativeTests/_01_02_NoRelevantConnectionTest.php +++ b/tests/FeatureTests/Security/Scenario01BasicNegativeTests/_01_02_NoRelevantConnectionTest.php @@ -127,11 +127,13 @@ public function test1020208(): void /** * @description test 1-02-02-20 + * + * @todo refactor in v0.2.0 with actual request required */ public function test1020220(): void { $response = $this->runGetRequest(sprintf('/%s/file', self::RELATION), self::TOKEN); - $this->assertIsProblemResponse($response, 404); + $this->assertIsProblemResponse($response, 501); } /** @@ -151,7 +153,7 @@ public function test1020221(): void ], ] ); - $this->assertIsProblemResponse($response, 404); + $this->assertIsProblemResponse($response, 501); } /** @@ -162,7 +164,7 @@ public function test1020221(): void public function test1020222(): void { $response = $this->runPutRequest(sprintf('/%s/file', self::RELATION), self::TOKEN, []); - $this->assertIsProblemResponse($response, 404); + $this->assertIsProblemResponse($response, 501); } /** @@ -173,16 +175,18 @@ public function test1020222(): void public function test1020223(): void { $response = $this->runPatchRequest(sprintf('/%s/file', self::RELATION), self::TOKEN, []); - $this->assertIsProblemResponse($response, 404); + $this->assertIsProblemResponse($response, 501); } /** * @description test 1-02-02-24 + * + * @todo refactor in v0.2.0 with actual request required */ public function test1020224(): void { $response = $this->runDeleteRequest(sprintf('/%s/file', self::RELATION), self::TOKEN); - $this->assertIsProblemResponse($response, 404); + $this->assertIsProblemResponse($response, 501); } /** @@ -193,7 +197,7 @@ public function test1020224(): void public function test1020230(): void { $response = $this->runCopyRequest(sprintf('/%s', self::RELATION), self::TOKEN); - $this->assertIsProblemResponse($response, 404); + $this->assertIsProblemResponse($response, 501); } /** @@ -204,7 +208,7 @@ public function test1020230(): void public function test1020231(): void { $response = $this->runLockRequest(sprintf('/%s', self::RELATION), self::TOKEN); - $this->assertIsProblemResponse($response, 404); + $this->assertIsProblemResponse($response, 501); } /** @@ -215,7 +219,7 @@ public function test1020231(): void public function test1020232(): void { $response = $this->runUnlockRequest(sprintf('/%s', self::RELATION), self::TOKEN); - $this->assertIsProblemResponse($response, 404); + $this->assertIsProblemResponse($response, 501); } /** @@ -226,7 +230,7 @@ public function test1020232(): void public function test1020233(): void { $response = $this->runMkcolRequest(sprintf('/%s', self::RELATION), self::TOKEN); - $this->assertIsProblemResponse($response, 404); + $this->assertIsProblemResponse($response, 501); } /** @@ -237,7 +241,7 @@ public function test1020233(): void public function test1020234(): void { $response = $this->runMoveRequest(sprintf('/%s', self::RELATION), self::TOKEN); - $this->assertIsProblemResponse($response, 404); + $this->assertIsProblemResponse($response, 501); } /** @@ -248,7 +252,7 @@ public function test1020234(): void public function test1020235(): void { $response = $this->runPropfindRequest(sprintf('/%s', self::RELATION), self::TOKEN); - $this->assertIsProblemResponse($response, 404); + $this->assertIsProblemResponse($response, 501); } /** @@ -259,7 +263,7 @@ public function test1020235(): void public function test1020236(): void { $response = $this->runProppatchRequest(sprintf('/%s', self::RELATION), self::TOKEN); - $this->assertIsProblemResponse($response, 404); + $this->assertIsProblemResponse($response, 501); } /** diff --git a/tests/FeatureTests/Security/Scenario01BasicNegativeTests/_01_03_MissingAccessToEitherStartOrEndNodeOfRelationshipsTest.php b/tests/FeatureTests/Security/Scenario01BasicNegativeTests/_01_03_MissingAccessToEitherStartOrEndNodeOfRelationshipsTest.php index 742ea00b..2e67745e 100644 --- a/tests/FeatureTests/Security/Scenario01BasicNegativeTests/_01_03_MissingAccessToEitherStartOrEndNodeOfRelationshipsTest.php +++ b/tests/FeatureTests/Security/Scenario01BasicNegativeTests/_01_03_MissingAccessToEitherStartOrEndNodeOfRelationshipsTest.php @@ -149,11 +149,13 @@ public function test1030408(): void /** * @description test 1-03-04-20 + * + * @todo refactor in v0.2.0 with actual request required */ public function test1030420(): void { $response = $this->runGetRequest(sprintf('/%s/file', self::RELATION_1), self::TOKEN); - $this->assertIsProblemResponse($response, 404); + $this->assertIsProblemResponse($response, 501); } /** @@ -173,7 +175,7 @@ public function test1030421(): void ], ] ); - $this->assertIsProblemResponse($response, 404); + $this->assertIsProblemResponse($response, 501); } /** @@ -184,7 +186,7 @@ public function test1030421(): void public function test1030422(): void { $response = $this->runPutRequest(sprintf('/%s/file', self::RELATION_1), self::TOKEN, []); - $this->assertIsProblemResponse($response, 404); + $this->assertIsProblemResponse($response, 501); } /** @@ -195,16 +197,18 @@ public function test1030422(): void public function test1030423(): void { $response = $this->runPatchRequest(sprintf('/%s/file', self::RELATION_1), self::TOKEN, []); - $this->assertIsProblemResponse($response, 404); + $this->assertIsProblemResponse($response, 501); } /** * @description test 1-03-04-24 + * + * @todo refactor in v0.2.0 with actual request required */ public function test1030424(): void { $response = $this->runDeleteRequest(sprintf('/%s/file', self::RELATION_1), self::TOKEN); - $this->assertIsProblemResponse($response, 404); + $this->assertIsProblemResponse($response, 501); } /** @@ -215,7 +219,7 @@ public function test1030424(): void public function test1030430(): void { $response = $this->runCopyRequest(sprintf('/%s', self::RELATION_1), self::TOKEN); - $this->assertIsProblemResponse($response, 404); + $this->assertIsProblemResponse($response, 501); } /** @@ -226,7 +230,7 @@ public function test1030430(): void public function test1030431(): void { $response = $this->runLockRequest(sprintf('/%s', self::RELATION_1), self::TOKEN); - $this->assertIsProblemResponse($response, 404); + $this->assertIsProblemResponse($response, 501); } /** @@ -237,7 +241,7 @@ public function test1030431(): void public function test1030432(): void { $response = $this->runUnlockRequest(sprintf('/%s', self::RELATION_1), self::TOKEN); - $this->assertIsProblemResponse($response, 404); + $this->assertIsProblemResponse($response, 501); } /** @@ -248,7 +252,7 @@ public function test1030432(): void public function test1030433(): void { $response = $this->runMkcolRequest(sprintf('/%s', self::RELATION_1), self::TOKEN); - $this->assertIsProblemResponse($response, 404); + $this->assertIsProblemResponse($response, 501); } /** @@ -259,7 +263,7 @@ public function test1030433(): void public function test1030434(): void { $response = $this->runMoveRequest(sprintf('/%s', self::RELATION_1), self::TOKEN); - $this->assertIsProblemResponse($response, 404); + $this->assertIsProblemResponse($response, 501); } /** @@ -270,7 +274,7 @@ public function test1030434(): void public function test1030435(): void { $response = $this->runPropfindRequest(sprintf('/%s', self::RELATION_1), self::TOKEN); - $this->assertIsProblemResponse($response, 404); + $this->assertIsProblemResponse($response, 501); } /** @@ -281,7 +285,7 @@ public function test1030435(): void public function test1030436(): void { $response = $this->runProppatchRequest(sprintf('/%s', self::RELATION_1), self::TOKEN); - $this->assertIsProblemResponse($response, 404); + $this->assertIsProblemResponse($response, 501); } /** @@ -391,11 +395,13 @@ public function test1030608(): void /** * @description test 1-03-06-20 + * + * @todo refactor in v0.2.0 with actual body content required */ public function test1030620(): void { $response = $this->runGetRequest(sprintf('/%s/file', self::RELATION_2), self::TOKEN); - $this->assertIsProblemResponse($response, 404); + $this->assertIsProblemResponse($response, 501); } /** @@ -415,7 +421,7 @@ public function test1030621(): void ], ] ); - $this->assertIsProblemResponse($response, 404); + $this->assertIsProblemResponse($response, 501); } /** @@ -426,7 +432,7 @@ public function test1030621(): void public function test1030622(): void { $response = $this->runPutRequest(sprintf('/%s/file', self::RELATION_2), self::TOKEN, []); - $this->assertIsProblemResponse($response, 404); + $this->assertIsProblemResponse($response, 501); } /** @@ -437,16 +443,18 @@ public function test1030622(): void public function test1030623(): void { $response = $this->runPatchRequest(sprintf('/%s/file', self::RELATION_2), self::TOKEN, []); - $this->assertIsProblemResponse($response, 404); + $this->assertIsProblemResponse($response, 501); } /** * @description test 1-03-06-24 + * + * @todo refactor in v0.2.0 with actual body content required */ public function test1030624(): void { $response = $this->runDeleteRequest(sprintf('/%s/file', self::RELATION_2), self::TOKEN); - $this->assertIsProblemResponse($response, 404); + $this->assertIsProblemResponse($response, 501); } /** @@ -457,7 +465,7 @@ public function test1030624(): void public function test1030630(): void { $response = $this->runCopyRequest(sprintf('/%s', self::RELATION_2), self::TOKEN); - $this->assertIsProblemResponse($response, 404); + $this->assertIsProblemResponse($response, 501); } /** @@ -468,7 +476,7 @@ public function test1030630(): void public function test1030631(): void { $response = $this->runLockRequest(sprintf('/%s', self::RELATION_2), self::TOKEN); - $this->assertIsProblemResponse($response, 404); + $this->assertIsProblemResponse($response, 501); } /** @@ -479,7 +487,7 @@ public function test1030631(): void public function test1030632(): void { $response = $this->runUnlockRequest(sprintf('/%s', self::RELATION_2), self::TOKEN); - $this->assertIsProblemResponse($response, 404); + $this->assertIsProblemResponse($response, 501); } /** @@ -490,7 +498,7 @@ public function test1030632(): void public function test1030633(): void { $response = $this->runMkcolRequest(sprintf('/%s', self::RELATION_2), self::TOKEN); - $this->assertIsProblemResponse($response, 404); + $this->assertIsProblemResponse($response, 501); } /** @@ -501,7 +509,7 @@ public function test1030633(): void public function test1030634(): void { $response = $this->runMoveRequest(sprintf('/%s', self::RELATION_2), self::TOKEN); - $this->assertIsProblemResponse($response, 404); + $this->assertIsProblemResponse($response, 501); } /** @@ -512,7 +520,7 @@ public function test1030634(): void public function test1030635(): void { $response = $this->runPropfindRequest(sprintf('/%s', self::RELATION_2), self::TOKEN); - $this->assertIsProblemResponse($response, 404); + $this->assertIsProblemResponse($response, 501); } /** @@ -523,7 +531,7 @@ public function test1030635(): void public function test1030636(): void { $response = $this->runProppatchRequest(sprintf('/%s', self::RELATION_2), self::TOKEN); - $this->assertIsProblemResponse($response, 404); + $this->assertIsProblemResponse($response, 501); } /** From 450a5998496e29ff726d70cb389e11fff6b051f0 Mon Sep 17 00:00:00 2001 From: Syndesi Date: Fri, 25 Aug 2023 22:56:49 +0200 Subject: [PATCH 5/9] Fix markdown files. --- docs/development/exceptions.md | 5 ----- 1 file changed, 5 deletions(-) diff --git a/docs/development/exceptions.md b/docs/development/exceptions.md index 13797eb9..8b51862d 100644 --- a/docs/development/exceptions.md +++ b/docs/development/exceptions.md @@ -9,8 +9,6 @@ List of all exceptions: - `404-not-found`: Default error if data does not exist, or user has no permission to read it. - `405-method-not-allowed`: Returned if user has READ access, but access to current method. - - | HTTP Status Code | Type | Title | Example Detail (prod) | Example Detail (dev) | | ---------------- | ----------------------------------------- | ---------------------------- | ------------------------------------------------------------ | ------------------------------------------------------------ | | 400 | `/error/400/missing-property` | Missing property | Endpoint requires that the request contains property 'x' to be set to Y. | Endpoint requires that the request contains property 'x' to be set to Y. | @@ -25,6 +23,3 @@ List of all exceptions: | 500 | `/error/500/internal-server-error` | Internal server error | Internal server error, see log. | 'error message'. | | 501 | `/error/501/not-implemented` | Not implemented | Endpoint is currently not implemented. | Endpoint is currently not implemented. | | 503 | `/error/503/service-unavailable` | Service unavailable | The service itself or an internal component is currently unavailable. | Service 'x' is currently unavailable. | -| | | | | | -| | | | | | - From d221f7a0ab3f8383e6a50772b618d00e7b112202 Mon Sep 17 00:00:00 2001 From: Syndesi Date: Sat, 26 Aug 2023 21:30:13 +0200 Subject: [PATCH 6/9] WIP rework exception and logging. --- docs/development/best-practices.md | 1 + ...ationElementDefragmentizeEventListener.php | 17 +++++---- ...ropertyElementFragmentizeEventListener.php | 3 +- ...ropertyElementFragmentizeEventListener.php | 9 +++-- .../NodeElementFragmentizeEventListener.php | 11 +++--- ...elationElementFragmentizeEventListener.php | 15 ++++---- ...ropertyElementFragmentizeEventListener.php | 3 +- ...atedElementPropertyChangeEventListener.php | 9 +++-- .../IdElementPropertyChangeEventListener.php | 9 +++-- ...okenElementPropertyChangeEventListener.php | 11 +++--- ...atedElementPropertyChangeEventListener.php | 9 +++-- ...UserElementPropertyChangeEventListener.php | 9 +++-- .../OwnershipChangeEventListener.php | 7 ++-- ...piKeyCheckOnKernelRequestEventListener.php | 11 +++--- src/Security/AuthProvider.php | 7 ++-- src/Service/CollectionService.php | 13 ++++--- src/Service/ElementManager.php | 7 ++-- src/Service/ElementResponseService.php | 7 ++-- src/Service/RawToElementService.php | 9 +++-- src/Style/EmberNexusStyle.php | 3 ++ ...ElementPropertyChangeEventListenerTest.php | 19 +++++++++- ...ElementPropertyChangeEventListenerTest.php | 19 +++++++++- ...ElementPropertyChangeEventListenerTest.php | 37 +++++++++++++++++-- ...ElementPropertyChangeEventListenerTest.php | 19 +++++++++- ...ElementPropertyChangeEventListenerTest.php | 36 ++++++++++++++++-- 25 files changed, 211 insertions(+), 89 deletions(-) diff --git a/docs/development/best-practices.md b/docs/development/best-practices.md index 28652b86..e077c762 100644 --- a/docs/development/best-practices.md +++ b/docs/development/best-practices.md @@ -46,6 +46,7 @@ Both log messages and exceptions should adhere to a few key principles: - Messages should provide context why they are created. - Messages should provide one specific reason, ideally a unique property or identifier. - Messages should not contain sensitive data like passwords, hashes, and tokens. +- Messages are sentences, they end with a dot. Log messages should be created in the following scenarios: diff --git a/src/EventSystem/ElementDefragmentize/EventListener/RelationElementDefragmentizeEventListener.php b/src/EventSystem/ElementDefragmentize/EventListener/RelationElementDefragmentizeEventListener.php index 0f539dca..c0b49067 100644 --- a/src/EventSystem/ElementDefragmentize/EventListener/RelationElementDefragmentizeEventListener.php +++ b/src/EventSystem/ElementDefragmentize/EventListener/RelationElementDefragmentizeEventListener.php @@ -3,13 +3,14 @@ namespace App\EventSystem\ElementDefragmentize\EventListener; use App\EventSystem\ElementDefragmentize\Event\RelationElementDefragmentizeEvent; -use InvalidArgumentException; +use App\Factory\Exception\Server500LogicExceptionFactory; use Ramsey\Uuid\Rfc4122\UuidV4; class RelationElementDefragmentizeEventListener { - public function __construct() - { + public function __construct( + private Server500LogicExceptionFactory $server500LogicExceptionFactory + ) { } public function onRelationElementDefragmentizeEvent(RelationElementDefragmentizeEvent $event): void @@ -18,27 +19,27 @@ public function onRelationElementDefragmentizeEvent(RelationElementDefragmentize $identifier = $cypherFragment->getProperty('id'); if (null === $identifier) { - throw new InvalidArgumentException(); + throw $this->server500LogicExceptionFactory->createFromTemplate('Relation element defragmentize event listener requires cypher fragment to contain valid UUID.'); } $identifier = UuidV4::fromString($identifier); $start = $cypherFragment->getStartNode(); if (null === $start) { - throw new InvalidArgumentException(); + throw $this->server500LogicExceptionFactory->createFromTemplate('Relation element defragmentize event listener requires cypher fragment to contain valid start node.'); } $start = $start->getProperty('id'); if (null === $start) { - throw new InvalidArgumentException(); + throw $this->server500LogicExceptionFactory->createFromTemplate('Relation element defragmentize event listener requires start node to have valid UUID.'); } $start = UuidV4::fromString($start); $end = $cypherFragment->getEndNode(); if (null === $end) { - throw new InvalidArgumentException(); + throw $this->server500LogicExceptionFactory->createFromTemplate('Relation element defragmentize event listener requires cypher fragment to contain valid end node.'); } $end = $end->getProperty('id'); if (null === $end) { - throw new InvalidArgumentException(); + throw $this->server500LogicExceptionFactory->createFromTemplate('Relation element defragmentize event listener requires end node to have valid UUID.'); } $end = UuidV4::fromString($end); diff --git a/src/EventSystem/ElementFragmentize/EventListener/CreatedPropertyElementFragmentizeEventListener.php b/src/EventSystem/ElementFragmentize/EventListener/CreatedPropertyElementFragmentizeEventListener.php index e229d5b7..3a327de6 100644 --- a/src/EventSystem/ElementFragmentize/EventListener/CreatedPropertyElementFragmentizeEventListener.php +++ b/src/EventSystem/ElementFragmentize/EventListener/CreatedPropertyElementFragmentizeEventListener.php @@ -6,7 +6,6 @@ use App\EventSystem\ElementFragmentize\Event\RelationElementFragmentizeEvent; use App\Factory\Exception\Server500InternalServerErrorExceptionFactory; use DateTimeInterface; -use Exception; use Laudis\Neo4j\Types\DateTimeZoneId; use MongoDB\BSON\UTCDateTime; @@ -45,7 +44,7 @@ private function handleEvent(NodeElementFragmentizeEvent|RelationElementFragment $created = $created->toDateTime(); } if (!($created instanceof DateTimeInterface)) { - throw new Exception("Unable to get datetime info from created property of type '".get_class($created)."'."); + throw $this->server500InternalServerErrorExceptionFactory->createFromTemplate("Unable to get datetime info from created property of type '".get_class($created)."'."); } $cypherFragment->addProperty('created', $created); $mongoFragment->addProperty('created', new UTCDateTime($created)); diff --git a/src/EventSystem/ElementFragmentize/EventListener/GenericPropertyElementFragmentizeEventListener.php b/src/EventSystem/ElementFragmentize/EventListener/GenericPropertyElementFragmentizeEventListener.php index 3e893154..c8e156e0 100644 --- a/src/EventSystem/ElementFragmentize/EventListener/GenericPropertyElementFragmentizeEventListener.php +++ b/src/EventSystem/ElementFragmentize/EventListener/GenericPropertyElementFragmentizeEventListener.php @@ -4,14 +4,15 @@ use App\EventSystem\ElementFragmentize\Event\NodeElementFragmentizeEvent; use App\EventSystem\ElementFragmentize\Event\RelationElementFragmentizeEvent; +use App\Factory\Exception\Server500InternalServerErrorExceptionFactory; use DateTimeInterface; -use Exception; use Laudis\Neo4j\Types\DateTimeZoneId; class GenericPropertyElementFragmentizeEventListener { - public function __construct() - { + public function __construct( + private Server500InternalServerErrorExceptionFactory $server500InternalServerErrorExceptionFactory + ) { } public function onNodeElementFragmentizeEvent(NodeElementFragmentizeEvent $event): void @@ -76,7 +77,7 @@ private function handleEvent(NodeElementFragmentizeEvent|RelationElementFragment $elasticFragment->addProperty($name, $value); continue; } - throw new Exception('unknown data type'); + throw $this->server500InternalServerErrorExceptionFactory->createFromTemplate(sprintf("Unknown data type with value '%s'.", $value)); } } } diff --git a/src/EventSystem/ElementFragmentize/EventListener/NodeElementFragmentizeEventListener.php b/src/EventSystem/ElementFragmentize/EventListener/NodeElementFragmentizeEventListener.php index 9c44b12c..ac2b7cd2 100644 --- a/src/EventSystem/ElementFragmentize/EventListener/NodeElementFragmentizeEventListener.php +++ b/src/EventSystem/ElementFragmentize/EventListener/NodeElementFragmentizeEventListener.php @@ -3,12 +3,13 @@ namespace App\EventSystem\ElementFragmentize\EventListener; use App\EventSystem\ElementFragmentize\Event\NodeElementFragmentizeEvent; -use InvalidArgumentException; +use App\Factory\Exception\Server500LogicExceptionFactory; class NodeElementFragmentizeEventListener { - public function __construct() - { + public function __construct( + private Server500LogicExceptionFactory $server500LogicExceptionFactory + ) { } public function onNodeElementFragmentizeEvent(NodeElementFragmentizeEvent $event): void @@ -17,13 +18,13 @@ public function onNodeElementFragmentizeEvent(NodeElementFragmentizeEvent $event $nodeElementIdentifier = $nodeElement->getIdentifier(); if (null === $nodeElementIdentifier) { - throw new InvalidArgumentException(); + throw $this->server500LogicExceptionFactory->createFromTemplate('Node element fragmentize event listener requires node to contain valid UUID.'); } $nodeElementIdentifier = $nodeElementIdentifier->toString(); $nodeLabel = $nodeElement->getLabel(); if (null === $nodeLabel) { - throw new InvalidArgumentException(); + throw $this->server500LogicExceptionFactory->createFromTemplate('Node element fragmentize event listener requires node to contain valid label.'); } /** diff --git a/src/EventSystem/ElementFragmentize/EventListener/RelationElementFragmentizeEventListener.php b/src/EventSystem/ElementFragmentize/EventListener/RelationElementFragmentizeEventListener.php index c967d6dd..cc54608d 100644 --- a/src/EventSystem/ElementFragmentize/EventListener/RelationElementFragmentizeEventListener.php +++ b/src/EventSystem/ElementFragmentize/EventListener/RelationElementFragmentizeEventListener.php @@ -3,13 +3,14 @@ namespace App\EventSystem\ElementFragmentize\EventListener; use App\EventSystem\ElementFragmentize\Event\RelationElementFragmentizeEvent; -use LogicException; +use App\Factory\Exception\Server500LogicExceptionFactory; use Syndesi\CypherDataStructures\Type\Node; class RelationElementFragmentizeEventListener { - public function __construct() - { + public function __construct( + private Server500LogicExceptionFactory $server500LogicExceptionFactory + ) { } public function onRelationElementFragmentizeEvent(RelationElementFragmentizeEvent $event): void @@ -18,24 +19,24 @@ public function onRelationElementFragmentizeEvent(RelationElementFragmentizeEven $relationUuid = $relationElement->getIdentifier(); if (null === $relationUuid) { - throw new LogicException(); + throw $this->server500LogicExceptionFactory->createFromTemplate('Relation element fragmentize event listener requires relation to contain valid UUID.'); } $relationUuid = $relationUuid->toString(); $relationType = $relationElement->getType(); if (null === $relationType) { - throw new LogicException(); + throw $this->server500LogicExceptionFactory->createFromTemplate('Relation element fragmentize event listener requires relation to contain valid type.'); } $startUuid = $relationElement->getStart(); if (null === $startUuid) { - throw new LogicException(); + throw $this->server500LogicExceptionFactory->createFromTemplate('Relation element fragmentize event listener requires relation to have valid start UUID.'); } $startUuid = $startUuid->toString(); $endUuid = $relationElement->getEnd(); if (null === $endUuid) { - throw new LogicException(); + throw $this->server500LogicExceptionFactory->createFromTemplate('Relation element fragmentize event listener requires relation to have valid end UUID.'); } $endUuid = $endUuid->toString(); diff --git a/src/EventSystem/ElementFragmentize/EventListener/UpdatedPropertyElementFragmentizeEventListener.php b/src/EventSystem/ElementFragmentize/EventListener/UpdatedPropertyElementFragmentizeEventListener.php index ed4c4aa6..cb1500d5 100644 --- a/src/EventSystem/ElementFragmentize/EventListener/UpdatedPropertyElementFragmentizeEventListener.php +++ b/src/EventSystem/ElementFragmentize/EventListener/UpdatedPropertyElementFragmentizeEventListener.php @@ -6,7 +6,6 @@ use App\EventSystem\ElementFragmentize\Event\RelationElementFragmentizeEvent; use App\Factory\Exception\Server500InternalServerErrorExceptionFactory; use DateTimeInterface; -use Exception; use Laudis\Neo4j\Types\DateTimeZoneId; use MongoDB\BSON\UTCDateTime; @@ -45,7 +44,7 @@ private function handleEvent(NodeElementFragmentizeEvent|RelationElementFragment $updated = $updated->toDateTime(); } if (!($updated instanceof DateTimeInterface)) { - throw new Exception("Unable to get datetime info from updated property of type '".get_class($updated)."'."); + throw $this->server500InternalServerErrorExceptionFactory->createFromTemplate("Unable to get datetime info from updated property of type '".get_class($updated)."'."); } $cypherFragment->addProperty('updated', $updated); $mongoFragment->addProperty('updated', new UTCDateTime($updated)); diff --git a/src/EventSystem/ElementPropertyChange/EventListener/CreatedElementPropertyChangeEventListener.php b/src/EventSystem/ElementPropertyChange/EventListener/CreatedElementPropertyChangeEventListener.php index 70893c54..22293878 100644 --- a/src/EventSystem/ElementPropertyChange/EventListener/CreatedElementPropertyChangeEventListener.php +++ b/src/EventSystem/ElementPropertyChange/EventListener/CreatedElementPropertyChangeEventListener.php @@ -3,12 +3,13 @@ namespace App\EventSystem\ElementPropertyChange\EventListener; use App\EventSystem\ElementPropertyChange\Event\ElementPropertyChangeEvent; -use Exception; +use App\Factory\Exception\Client400ForbiddenPropertyExceptionFactory; class CreatedElementPropertyChangeEventListener { - public function __construct() - { + public function __construct( + private Client400ForbiddenPropertyExceptionFactory $client400ForbiddenPropertyExceptionFactory + ) { } public function onElementPropertyChangeEvent(ElementPropertyChangeEvent $event): void @@ -16,6 +17,6 @@ public function onElementPropertyChangeEvent(ElementPropertyChangeEvent $event): if (!array_key_exists('created', $event->getChangedProperties())) { return; } - throw new Exception("Setting the property 'created' is forbidden."); + throw $this->client400ForbiddenPropertyExceptionFactory->createFromTemplate('created'); } } diff --git a/src/EventSystem/ElementPropertyChange/EventListener/IdElementPropertyChangeEventListener.php b/src/EventSystem/ElementPropertyChange/EventListener/IdElementPropertyChangeEventListener.php index 441c2d10..c1156048 100644 --- a/src/EventSystem/ElementPropertyChange/EventListener/IdElementPropertyChangeEventListener.php +++ b/src/EventSystem/ElementPropertyChange/EventListener/IdElementPropertyChangeEventListener.php @@ -3,12 +3,13 @@ namespace App\EventSystem\ElementPropertyChange\EventListener; use App\EventSystem\ElementPropertyChange\Event\ElementPropertyChangeEvent; -use Exception; +use App\Factory\Exception\Client400ForbiddenPropertyExceptionFactory; class IdElementPropertyChangeEventListener { - public function __construct() - { + public function __construct( + private Client400ForbiddenPropertyExceptionFactory $client400ForbiddenPropertyExceptionFactory + ) { } public function onElementPropertyChangeEvent(ElementPropertyChangeEvent $event): void @@ -16,6 +17,6 @@ public function onElementPropertyChangeEvent(ElementPropertyChangeEvent $event): if (!array_key_exists('id', $event->getChangedProperties())) { return; } - throw new Exception("Setting the property 'id' is forbidden."); + throw $this->client400ForbiddenPropertyExceptionFactory->createFromTemplate('id'); } } diff --git a/src/EventSystem/ElementPropertyChange/EventListener/TokenElementPropertyChangeEventListener.php b/src/EventSystem/ElementPropertyChange/EventListener/TokenElementPropertyChangeEventListener.php index d7b4779a..1bcd5431 100644 --- a/src/EventSystem/ElementPropertyChange/EventListener/TokenElementPropertyChangeEventListener.php +++ b/src/EventSystem/ElementPropertyChange/EventListener/TokenElementPropertyChangeEventListener.php @@ -3,12 +3,13 @@ namespace App\EventSystem\ElementPropertyChange\EventListener; use App\EventSystem\ElementPropertyChange\Event\ElementPropertyChangeEvent; -use Exception; +use App\Factory\Exception\Client400ForbiddenPropertyExceptionFactory; class TokenElementPropertyChangeEventListener { - public function __construct() - { + public function __construct( + private Client400ForbiddenPropertyExceptionFactory $client400ForbiddenPropertyExceptionFactory + ) { } public function onElementPropertyChangeEvent(ElementPropertyChangeEvent $event): void @@ -17,10 +18,10 @@ public function onElementPropertyChangeEvent(ElementPropertyChangeEvent $event): return; } if (array_key_exists('token', $event->getChangedProperties())) { - throw new Exception("Setting the property 'token' is forbidden."); + throw $this->client400ForbiddenPropertyExceptionFactory->createFromTemplate('token'); } if (array_key_exists('_tokenHash', $event->getChangedProperties())) { - throw new Exception("Setting the property '_tokenHash' is forbidden."); + throw $this->client400ForbiddenPropertyExceptionFactory->createFromTemplate('_tokenHash'); } } } diff --git a/src/EventSystem/ElementPropertyChange/EventListener/UpdatedElementPropertyChangeEventListener.php b/src/EventSystem/ElementPropertyChange/EventListener/UpdatedElementPropertyChangeEventListener.php index fa3daac2..be9dec94 100644 --- a/src/EventSystem/ElementPropertyChange/EventListener/UpdatedElementPropertyChangeEventListener.php +++ b/src/EventSystem/ElementPropertyChange/EventListener/UpdatedElementPropertyChangeEventListener.php @@ -3,12 +3,13 @@ namespace App\EventSystem\ElementPropertyChange\EventListener; use App\EventSystem\ElementPropertyChange\Event\ElementPropertyChangeEvent; -use Exception; +use App\Factory\Exception\Client400ForbiddenPropertyExceptionFactory; class UpdatedElementPropertyChangeEventListener { - public function __construct() - { + public function __construct( + private Client400ForbiddenPropertyExceptionFactory $client400ForbiddenPropertyExceptionFactory + ) { } public function onElementPropertyChangeEvent(ElementPropertyChangeEvent $event): void @@ -16,6 +17,6 @@ public function onElementPropertyChangeEvent(ElementPropertyChangeEvent $event): if (!array_key_exists('updated', $event->getChangedProperties())) { return; } - throw new Exception("Setting the property 'updated' is forbidden."); + throw $this->client400ForbiddenPropertyExceptionFactory->createFromTemplate('updated'); } } diff --git a/src/EventSystem/ElementPropertyChange/EventListener/UserElementPropertyChangeEventListener.php b/src/EventSystem/ElementPropertyChange/EventListener/UserElementPropertyChangeEventListener.php index a7933364..f4a803ce 100644 --- a/src/EventSystem/ElementPropertyChange/EventListener/UserElementPropertyChangeEventListener.php +++ b/src/EventSystem/ElementPropertyChange/EventListener/UserElementPropertyChangeEventListener.php @@ -3,13 +3,14 @@ namespace App\EventSystem\ElementPropertyChange\EventListener; use App\EventSystem\ElementPropertyChange\Event\ElementPropertyChangeEvent; +use App\Factory\Exception\Client400ForbiddenPropertyExceptionFactory; use EmberNexusBundle\Service\EmberNexusConfiguration; -use Exception; class UserElementPropertyChangeEventListener { public function __construct( - private EmberNexusConfiguration $emberNexusConfiguration + private EmberNexusConfiguration $emberNexusConfiguration, + private Client400ForbiddenPropertyExceptionFactory $client400ForbiddenPropertyExceptionFactory ) { } @@ -19,10 +20,10 @@ public function onElementPropertyChangeEvent(ElementPropertyChangeEvent $event): return; } if (array_key_exists('_passwordHash', $event->getChangedProperties())) { - throw new Exception("Setting the property '_passwordHash' is forbidden."); + throw $this->client400ForbiddenPropertyExceptionFactory->createFromTemplate('_passwordHash'); } if (array_key_exists($this->emberNexusConfiguration->getRegisterUniqueIdentifier(), $event->getChangedProperties())) { - throw new Exception(sprintf("Setting the property '%s' is forbidden.", $this->emberNexusConfiguration->getRegisterUniqueIdentifier())); + throw $this->client400ForbiddenPropertyExceptionFactory->createFromTemplate($this->emberNexusConfiguration->getRegisterUniqueIdentifier()); } } } diff --git a/src/EventSystem/EntityManager/EventListener/OwnershipChangeEventListener.php b/src/EventSystem/EntityManager/EventListener/OwnershipChangeEventListener.php index a48b61d9..e06f1960 100644 --- a/src/EventSystem/EntityManager/EventListener/OwnershipChangeEventListener.php +++ b/src/EventSystem/EntityManager/EventListener/OwnershipChangeEventListener.php @@ -6,8 +6,8 @@ use App\EventSystem\EntityManager\Event\ElementPostCreateEvent; use App\EventSystem\EntityManager\Event\ElementPostDeleteEvent; use App\EventSystem\EntityManager\Event\ElementPostMergeEvent; +use App\Factory\Exception\Server500InternalServerErrorExceptionFactory; use App\Type\RabbitMQQueueType; -use Exception; use PhpAmqpLib\Connection\AMQPStreamConnection; use PhpAmqpLib\Message\AMQPMessage; @@ -27,7 +27,8 @@ class OwnershipChangeEventListener ]; public function __construct( - private AMQPStreamConnection $AMQPStreamConnection + private AMQPStreamConnection $AMQPStreamConnection, + private Server500InternalServerErrorExceptionFactory $server500InternalServerErrorExceptionFactory ) { } @@ -74,7 +75,7 @@ public function handleOwnershipChange(RelationElementInterface $element): void 'element' => $elementId->toString(), ], JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES); if (!is_string($jsonMessage)) { - throw new Exception('Internal server exception.'); + throw $this->server500InternalServerErrorExceptionFactory->createFromTemplate('Problem with internal JSON encoding.'); } $message = new AMQPMessage($jsonMessage); $channel->basic_publish($message, '', $queue); diff --git a/src/EventSystem/Request/EventListener/ApiKeyCheckOnKernelRequestEventListener.php b/src/EventSystem/Request/EventListener/ApiKeyCheckOnKernelRequestEventListener.php index 0ed27f5e..701c9b6e 100644 --- a/src/EventSystem/Request/EventListener/ApiKeyCheckOnKernelRequestEventListener.php +++ b/src/EventSystem/Request/EventListener/ApiKeyCheckOnKernelRequestEventListener.php @@ -2,7 +2,7 @@ namespace App\EventSystem\Request\EventListener; -use App\Exception\Client401UnauthorizedException; +use App\Factory\Exception\Client401UnauthorizedExceptionFactory; use App\Security\AuthProvider; use App\Security\TokenGenerator; use App\Type\UserUuidAndTokenUuidObject; @@ -22,7 +22,8 @@ public function __construct( private TokenGenerator $tokenGenerator, private CypherEntityManager $cypherEntityManager, private Client $redisClient, - private AuthProvider $authProvider + private AuthProvider $authProvider, + private Client401UnauthorizedExceptionFactory $client401UnauthorizedExceptionFactory ) { } @@ -63,7 +64,7 @@ private function getUserUuidAndTokenUuidObjectFromTokenFromCypher(string $token) ); if (0 === count($res)) { - throw new Client401UnauthorizedException('Invalid authorization token'); + throw $this->client401UnauthorizedExceptionFactory->createFromTemplate(); } $userUuid = Uuid::fromString($res->first()->get('user.id')); @@ -110,11 +111,11 @@ private function extractTokenFromRequest(Request $request): string { $tokenParts = explode(' ', $request->headers->get('Authorization') ?? '', 2); if (2 !== count($tokenParts)) { - throw new Client401UnauthorizedException('Invalid authorization token'); + throw $this->client401UnauthorizedExceptionFactory->createFromTemplate(); } $token = $tokenParts[1]; if (!str_starts_with($token, 'secret-token:')) { - throw new Client401UnauthorizedException('Invalid authorization token'); + throw $this->client401UnauthorizedExceptionFactory->createFromTemplate(); } return $token; diff --git a/src/Security/AuthProvider.php b/src/Security/AuthProvider.php index a10eb571..4b5a4e82 100755 --- a/src/Security/AuthProvider.php +++ b/src/Security/AuthProvider.php @@ -2,7 +2,7 @@ namespace App\Security; -use LogicException; +use App\Factory\Exception\Server500LogicExceptionFactory; use Ramsey\Uuid\Rfc4122\UuidV4; use Ramsey\Uuid\UuidInterface; use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface; @@ -14,11 +14,12 @@ class AuthProvider private ?UuidInterface $tokenUuid = null; public function __construct( - private ParameterBagInterface $bag + private ParameterBagInterface $bag, + private Server500LogicExceptionFactory $server500LogicExceptionFactory ) { $anonymousUserUuid = $this->bag->get('anonymousUserUUID'); if (!is_string($anonymousUserUuid)) { - throw new LogicException('anonymousUserUUID must be set to a valid UUID'); + throw $this->server500LogicExceptionFactory->createFromTemplate('anonymousUserUUID must be set to a valid UUID'); } $this->userUuid = UuidV4::fromString($anonymousUserUuid); $this->isAnonymous = true; diff --git a/src/Service/CollectionService.php b/src/Service/CollectionService.php index dbca6ced..5ba1de00 100755 --- a/src/Service/CollectionService.php +++ b/src/Service/CollectionService.php @@ -2,9 +2,10 @@ namespace App\Service; +use App\Factory\Exception\Server500InternalServerErrorExceptionFactory; +use App\Factory\Exception\Server500LogicExceptionFactory; use App\Response\CollectionResponse; use EmberNexusBundle\Service\EmberNexusConfiguration; -use LogicException; use Ramsey\Uuid\UuidInterface; use Symfony\Component\HttpFoundation\InputBag; use Symfony\Component\HttpFoundation\RequestStack; @@ -15,7 +16,9 @@ public function __construct( private RequestStack $requestStack, private ElementManager $elementManager, private ElementToRawService $elementToRawService, - private EmberNexusConfiguration $emberNexusConfiguration + private EmberNexusConfiguration $emberNexusConfiguration, + private Server500InternalServerErrorExceptionFactory $server500InternalServerErrorExceptionFactory, + private Server500LogicExceptionFactory $server500LogicExceptionFactory ) { } @@ -24,7 +27,7 @@ public function getCurrentPage(): int $firstPage = 1; $query = $this->requestStack->getCurrentRequest()?->query; if (!($query instanceof InputBag)) { - throw new LogicException(); + throw $this->server500InternalServerErrorExceptionFactory->createFromTemplate('Query must be an instance of InputBag.'); } if (!$query->has('page')) { return $firstPage; @@ -41,7 +44,7 @@ public function getPageSize(): int { $query = $this->requestStack->getCurrentRequest()?->query; if (!($query instanceof InputBag)) { - throw new LogicException(); + throw $this->server500InternalServerErrorExceptionFactory->createFromTemplate('Query must be an instance of InputBag.'); } if (!$query->has('pageSize')) { return $this->emberNexusConfiguration->getPageSizeDefault(); @@ -69,7 +72,7 @@ public function getPageLink(int $page = null): string { $currentRequest = $this->requestStack->getCurrentRequest(); if (null === $currentRequest) { - throw new LogicException(); + throw $this->server500LogicExceptionFactory->createFromTemplate('Current request can not be null.'); } $basePath = $currentRequest->getBasePath(); diff --git a/src/Service/ElementManager.php b/src/Service/ElementManager.php index 3a14dc4f..587e6f64 100755 --- a/src/Service/ElementManager.php +++ b/src/Service/ElementManager.php @@ -10,9 +10,9 @@ use App\EventSystem\EntityManager\Event\ElementPreCreateEvent; use App\EventSystem\EntityManager\Event\ElementPreDeleteEvent; use App\EventSystem\EntityManager\Event\ElementPreMergeEvent; +use App\Factory\Exception\Server500LogicExceptionFactory; use App\Helper\Neo4jClientHelper; use Laudis\Neo4j\Databags\Statement; -use LogicException; use OutOfBoundsException; use Psr\EventDispatcher\EventDispatcherInterface; use Ramsey\Uuid\UuidInterface; @@ -42,7 +42,8 @@ public function __construct( private ElementFragmentizeService $elementFragmentizeService, private ElementDefragmentizeService $elementDefragmentizeService, private Neo4jClientHelper $neo4jClientHelper, - private EventDispatcherInterface $eventDispatcher + private EventDispatcherInterface $eventDispatcher, + private Server500LogicExceptionFactory $server500LogicExceptionFactory ) { } @@ -180,7 +181,7 @@ public function getRelation(UuidInterface $uuid): ?RelationElementInterface } $type = $cypherFragment->getType(); if (null === $type) { - throw new LogicException('Unable to get relationship type'); + throw $this->server500LogicExceptionFactory->createFromTemplate('Unable to get relationship type.'); } $documentFragment = $this->mongoEntityManager->getOneByIdentifier($type, $uuid->toString()); diff --git a/src/Service/ElementResponseService.php b/src/Service/ElementResponseService.php index 104d40ac..424bb38f 100755 --- a/src/Service/ElementResponseService.php +++ b/src/Service/ElementResponseService.php @@ -2,15 +2,16 @@ namespace App\Service; +use App\Factory\Exception\Server500LogicExceptionFactory; use App\Response\ElementResponse; -use LogicException; use Ramsey\Uuid\UuidInterface; class ElementResponseService { public function __construct( private ElementManager $elementManager, - private ElementToRawService $elementToRawService + private ElementToRawService $elementToRawService, + private Server500LogicExceptionFactory $server500LogicExceptionFactory ) { } @@ -19,7 +20,7 @@ public function buildElementResponseFromUuid( ): ElementResponse { $element = $this->elementManager->getElement($uuid); if (null === $element) { - throw new LogicException(sprintf("Unable to find element with the id '%s'.", $uuid->toString())); + throw $this->server500LogicExceptionFactory->createFromTemplate(sprintf("Unable to find element with the id '%s'.", $uuid->toString())); } $rawData = $this->elementToRawService->elementToRaw($element); diff --git a/src/Service/RawToElementService.php b/src/Service/RawToElementService.php index 9a33bbdc..fdd9d37b 100755 --- a/src/Service/RawToElementService.php +++ b/src/Service/RawToElementService.php @@ -5,16 +5,17 @@ use App\Contract\NodeElementInterface; use App\Contract\RelationElementInterface; use App\EventSystem\RawValueToNormalizedValue\Event\RawValueToNormalizedValueEvent; +use App\Factory\Exception\Client400MissingPropertyExceptionFactory; use App\Type\NodeElement; use App\Type\RelationElement; -use Exception; use Psr\EventDispatcher\EventDispatcherInterface; use Ramsey\Uuid\Uuid; class RawToElementService { public function __construct( - private EventDispatcherInterface $eventDispatcher + private EventDispatcherInterface $eventDispatcher, + private Client400MissingPropertyExceptionFactory $client400MissingPropertyExceptionFactory ) { } @@ -24,12 +25,12 @@ public function __construct( public function rawToElement(array $rawData): NodeElementInterface|RelationElementInterface { if (!array_key_exists('type', $rawData)) { - throw new Exception("Unable to find required property 'type' in raw data."); + throw $this->client400MissingPropertyExceptionFactory->createFromTemplate('type', 'valid type'); } $type = $rawData['type']; if (!array_key_exists('id', $rawData)) { - throw new Exception("Unable to find required property 'id' in raw data."); + throw $this->client400MissingPropertyExceptionFactory->createFromTemplate('id', 'valid UUID'); } $id = Uuid::fromString($rawData['id']); diff --git a/src/Style/EmberNexusStyle.php b/src/Style/EmberNexusStyle.php index 61ee12c3..21ed8f42 100755 --- a/src/Style/EmberNexusStyle.php +++ b/src/Style/EmberNexusStyle.php @@ -75,6 +75,9 @@ public function title(string $message): void public function success(array|string $message): void { if ($this->isInSection) { + /* + * todo replace exception with new exception factory - requires ember nexus style factory itself + */ throw new Exception('Function success() should only be called at end of command, not within sections.'); } if (is_string($message)) { diff --git a/tests/UnitTests/EventSystem/ElementPropertyChange/EventListener/CreatedElementPropertyChangeEventListenerTest.php b/tests/UnitTests/EventSystem/ElementPropertyChange/EventListener/CreatedElementPropertyChangeEventListenerTest.php index 9f8ac11f..b040edbc 100644 --- a/tests/UnitTests/EventSystem/ElementPropertyChange/EventListener/CreatedElementPropertyChangeEventListenerTest.php +++ b/tests/UnitTests/EventSystem/ElementPropertyChange/EventListener/CreatedElementPropertyChangeEventListenerTest.php @@ -4,16 +4,24 @@ use App\EventSystem\ElementPropertyChange\Event\ElementPropertyChangeEvent; use App\EventSystem\ElementPropertyChange\EventListener\CreatedElementPropertyChangeEventListener; +use App\Factory\Exception\Client400ForbiddenPropertyExceptionFactory; use Exception; use PHPUnit\Framework\TestCase; +use Prophecy\Argument; +use Prophecy\PhpUnit\ProphecyTrait; +use Symfony\Component\Routing\Generator\UrlGeneratorInterface; class CreatedElementPropertyChangeEventListenerTest extends TestCase { + use ProphecyTrait; + public function testElementsWithoutCreatedPropertyAreIgnored(): void { self::expectNotToPerformAssertions(); $event = new ElementPropertyChangeEvent('Test', null, ['name' => 'Test']); - $eventListener = new CreatedElementPropertyChangeEventListener(); + $eventListener = new CreatedElementPropertyChangeEventListener( + $this->prophesize(Client400ForbiddenPropertyExceptionFactory::class)->reveal() + ); $eventListener->onElementPropertyChangeEvent($event); } @@ -23,7 +31,14 @@ public function testElementWithCreatedPropertyTriggersException(): void $this->markTestSkipped(); } $event = new ElementPropertyChangeEvent('Test', null, ['created' => true]); - $eventListener = new CreatedElementPropertyChangeEventListener(); + $urlGenerator = $this->prophesize(UrlGeneratorInterface::class); + $urlGenerator->generate(Argument::cetera()) + ->willReturn('http://example.com/url-to-error'); + $eventListener = new CreatedElementPropertyChangeEventListener( + new Client400ForbiddenPropertyExceptionFactory( + $urlGenerator->reveal() + ) + ); $this->expectException(Exception::class); $eventListener->onElementPropertyChangeEvent($event); } diff --git a/tests/UnitTests/EventSystem/ElementPropertyChange/EventListener/IdElementPropertyChangeEventListenerTest.php b/tests/UnitTests/EventSystem/ElementPropertyChange/EventListener/IdElementPropertyChangeEventListenerTest.php index de04f86f..40a6f1ad 100644 --- a/tests/UnitTests/EventSystem/ElementPropertyChange/EventListener/IdElementPropertyChangeEventListenerTest.php +++ b/tests/UnitTests/EventSystem/ElementPropertyChange/EventListener/IdElementPropertyChangeEventListenerTest.php @@ -4,16 +4,24 @@ use App\EventSystem\ElementPropertyChange\Event\ElementPropertyChangeEvent; use App\EventSystem\ElementPropertyChange\EventListener\IdElementPropertyChangeEventListener; +use App\Factory\Exception\Client400ForbiddenPropertyExceptionFactory; use Exception; use PHPUnit\Framework\TestCase; +use Prophecy\Argument; +use Prophecy\PhpUnit\ProphecyTrait; +use Symfony\Component\Routing\Generator\UrlGeneratorInterface; class IdElementPropertyChangeEventListenerTest extends TestCase { + use ProphecyTrait; + public function testElementsWithoutIdPropertyAreIgnored(): void { self::expectNotToPerformAssertions(); $event = new ElementPropertyChangeEvent('Test', null, ['name' => 'Test']); - $eventListener = new IdElementPropertyChangeEventListener(); + $eventListener = new IdElementPropertyChangeEventListener( + $this->prophesize(Client400ForbiddenPropertyExceptionFactory::class)->reveal() + ); $eventListener->onElementPropertyChangeEvent($event); } @@ -23,7 +31,14 @@ public function testElementWithIdPropertyTriggersException(): void $this->markTestSkipped(); } $event = new ElementPropertyChangeEvent('Test', null, ['id' => true]); - $eventListener = new IdElementPropertyChangeEventListener(); + $urlGenerator = $this->prophesize(UrlGeneratorInterface::class); + $urlGenerator->generate(Argument::cetera()) + ->willReturn('http://example.com/url-to-error'); + $eventListener = new IdElementPropertyChangeEventListener( + new Client400ForbiddenPropertyExceptionFactory( + $urlGenerator->reveal() + ) + ); $this->expectException(Exception::class); $eventListener->onElementPropertyChangeEvent($event); } diff --git a/tests/UnitTests/EventSystem/ElementPropertyChange/EventListener/TokenElementPropertyChangeEventListenerTest.php b/tests/UnitTests/EventSystem/ElementPropertyChange/EventListener/TokenElementPropertyChangeEventListenerTest.php index aca6fca5..fcfa7187 100644 --- a/tests/UnitTests/EventSystem/ElementPropertyChange/EventListener/TokenElementPropertyChangeEventListenerTest.php +++ b/tests/UnitTests/EventSystem/ElementPropertyChange/EventListener/TokenElementPropertyChangeEventListenerTest.php @@ -4,16 +4,24 @@ use App\EventSystem\ElementPropertyChange\Event\ElementPropertyChangeEvent; use App\EventSystem\ElementPropertyChange\EventListener\TokenElementPropertyChangeEventListener; +use App\Factory\Exception\Client400ForbiddenPropertyExceptionFactory; use Exception; use PHPUnit\Framework\TestCase; +use Prophecy\Argument; +use Prophecy\PhpUnit\ProphecyTrait; +use Symfony\Component\Routing\Generator\UrlGeneratorInterface; class TokenElementPropertyChangeEventListenerTest extends TestCase { + use ProphecyTrait; + public function testElementsWhichAreNotTokensAreIgnored(): void { self::expectNotToPerformAssertions(); $event = new ElementPropertyChangeEvent('Test', null, ['name' => 'Test']); - $eventListener = new TokenElementPropertyChangeEventListener(); + $eventListener = new TokenElementPropertyChangeEventListener( + $this->prophesize(Client400ForbiddenPropertyExceptionFactory::class)->reveal() + ); $eventListener->onElementPropertyChangeEvent($event); } @@ -21,7 +29,14 @@ public function testTokensWithNoTokenOrTokenHashPropertiesAreIgnored(): void { self::expectNotToPerformAssertions(); $event = new ElementPropertyChangeEvent('Token', null, ['name' => 'Test']); - $eventListener = new TokenElementPropertyChangeEventListener(); + $urlGenerator = $this->prophesize(UrlGeneratorInterface::class); + $urlGenerator->generate(Argument::cetera()) + ->willReturn('http://example.com/url-to-error'); + $eventListener = new TokenElementPropertyChangeEventListener( + new Client400ForbiddenPropertyExceptionFactory( + $urlGenerator->reveal() + ) + ); $eventListener->onElementPropertyChangeEvent($event); } @@ -31,7 +46,14 @@ public function testTokenWithTokenPropertyTriggersException(): void $this->markTestSkipped(); } $event = new ElementPropertyChangeEvent('Token', null, ['token' => true]); - $eventListener = new TokenElementPropertyChangeEventListener(); + $urlGenerator = $this->prophesize(UrlGeneratorInterface::class); + $urlGenerator->generate(Argument::cetera()) + ->willReturn('http://example.com/url-to-error'); + $eventListener = new TokenElementPropertyChangeEventListener( + new Client400ForbiddenPropertyExceptionFactory( + $urlGenerator->reveal() + ) + ); $this->expectException(Exception::class); $eventListener->onElementPropertyChangeEvent($event); } @@ -42,7 +64,14 @@ public function testTokenWithTokenHashPropertyTriggersException(): void $this->markTestSkipped(); } $event = new ElementPropertyChangeEvent('Token', null, ['_tokenHash' => true]); - $eventListener = new TokenElementPropertyChangeEventListener(); + $urlGenerator = $this->prophesize(UrlGeneratorInterface::class); + $urlGenerator->generate(Argument::cetera()) + ->willReturn('http://example.com/url-to-error'); + $eventListener = new TokenElementPropertyChangeEventListener( + new Client400ForbiddenPropertyExceptionFactory( + $urlGenerator->reveal() + ) + ); $this->expectException(Exception::class); $eventListener->onElementPropertyChangeEvent($event); } diff --git a/tests/UnitTests/EventSystem/ElementPropertyChange/EventListener/UpdatedElementPropertyChangeEventListenerTest.php b/tests/UnitTests/EventSystem/ElementPropertyChange/EventListener/UpdatedElementPropertyChangeEventListenerTest.php index 34dd9c9b..f97538eb 100644 --- a/tests/UnitTests/EventSystem/ElementPropertyChange/EventListener/UpdatedElementPropertyChangeEventListenerTest.php +++ b/tests/UnitTests/EventSystem/ElementPropertyChange/EventListener/UpdatedElementPropertyChangeEventListenerTest.php @@ -4,16 +4,24 @@ use App\EventSystem\ElementPropertyChange\Event\ElementPropertyChangeEvent; use App\EventSystem\ElementPropertyChange\EventListener\UpdatedElementPropertyChangeEventListener; +use App\Factory\Exception\Client400ForbiddenPropertyExceptionFactory; use Exception; use PHPUnit\Framework\TestCase; +use Prophecy\Argument; +use Prophecy\PhpUnit\ProphecyTrait; +use Symfony\Component\Routing\Generator\UrlGeneratorInterface; class UpdatedElementPropertyChangeEventListenerTest extends TestCase { + use ProphecyTrait; + public function testElementsWithoutUpdatedPropertyAreIgnored(): void { self::expectNotToPerformAssertions(); $event = new ElementPropertyChangeEvent('Test', null, ['name' => 'Test']); - $eventListener = new UpdatedElementPropertyChangeEventListener(); + $eventListener = new UpdatedElementPropertyChangeEventListener( + $this->prophesize(Client400ForbiddenPropertyExceptionFactory::class)->reveal() + ); $eventListener->onElementPropertyChangeEvent($event); } @@ -23,7 +31,14 @@ public function testElementWithUpdatedPropertyTriggersException(): void $this->markTestSkipped(); } $event = new ElementPropertyChangeEvent('Test', null, ['updated' => true]); - $eventListener = new UpdatedElementPropertyChangeEventListener(); + $urlGenerator = $this->prophesize(UrlGeneratorInterface::class); + $urlGenerator->generate(Argument::cetera()) + ->willReturn('http://example.com/url-to-error'); + $eventListener = new UpdatedElementPropertyChangeEventListener( + new Client400ForbiddenPropertyExceptionFactory( + $urlGenerator->reveal() + ) + ); $this->expectException(Exception::class); $eventListener->onElementPropertyChangeEvent($event); } diff --git a/tests/UnitTests/EventSystem/ElementPropertyChange/EventListener/UserElementPropertyChangeEventListenerTest.php b/tests/UnitTests/EventSystem/ElementPropertyChange/EventListener/UserElementPropertyChangeEventListenerTest.php index 3c605e4b..0caeec12 100644 --- a/tests/UnitTests/EventSystem/ElementPropertyChange/EventListener/UserElementPropertyChangeEventListenerTest.php +++ b/tests/UnitTests/EventSystem/ElementPropertyChange/EventListener/UserElementPropertyChangeEventListenerTest.php @@ -4,10 +4,13 @@ use App\EventSystem\ElementPropertyChange\Event\ElementPropertyChangeEvent; use App\EventSystem\ElementPropertyChange\EventListener\UserElementPropertyChangeEventListener; +use App\Factory\Exception\Client400ForbiddenPropertyExceptionFactory; use EmberNexusBundle\Service\EmberNexusConfiguration; use Exception; use PHPUnit\Framework\TestCase; +use Prophecy\Argument; use Prophecy\PhpUnit\ProphecyTrait; +use Symfony\Component\Routing\Generator\UrlGeneratorInterface; class UserElementPropertyChangeEventListenerTest extends TestCase { @@ -18,7 +21,8 @@ public function testElementsWhichAreNotUsersAreIgnored(): void self::expectNotToPerformAssertions(); $event = new ElementPropertyChangeEvent('Test', null, ['name' => 'Test']); $eventListener = new UserElementPropertyChangeEventListener( - $this->prophesize(EmberNexusConfiguration::class)->reveal() + $this->prophesize(EmberNexusConfiguration::class)->reveal(), + $this->prophesize(Client400ForbiddenPropertyExceptionFactory::class)->reveal() ); $eventListener->onElementPropertyChangeEvent($event); } @@ -29,7 +33,15 @@ public function testUsersWithNoPasswordHashOrUniqueIdentifyingPropertiesAreIgnor $emberNexusConfiguration->getRegisterUniqueIdentifier()->willReturn('email'); self::expectNotToPerformAssertions(); $event = new ElementPropertyChangeEvent('User', null, ['name' => 'Test']); - $eventListener = new UserElementPropertyChangeEventListener($emberNexusConfiguration->reveal()); + $urlGenerator = $this->prophesize(UrlGeneratorInterface::class); + $urlGenerator->generate(Argument::cetera()) + ->willReturn('http://example.com/url-to-error'); + $eventListener = new UserElementPropertyChangeEventListener( + $emberNexusConfiguration->reveal(), + new Client400ForbiddenPropertyExceptionFactory( + $urlGenerator->reveal() + ) + ); $eventListener->onElementPropertyChangeEvent($event); } @@ -41,7 +53,15 @@ public function testUserWithPasswordHashPropertyTriggersException(): void $emberNexusConfiguration = $this->prophesize(EmberNexusConfiguration::class); $emberNexusConfiguration->getRegisterUniqueIdentifier()->willReturn('email'); $event = new ElementPropertyChangeEvent('User', null, ['_passwordHash' => true]); - $eventListener = new UserElementPropertyChangeEventListener($emberNexusConfiguration->reveal()); + $urlGenerator = $this->prophesize(UrlGeneratorInterface::class); + $urlGenerator->generate(Argument::cetera()) + ->willReturn('http://example.com/url-to-error'); + $eventListener = new UserElementPropertyChangeEventListener( + $emberNexusConfiguration->reveal(), + new Client400ForbiddenPropertyExceptionFactory( + $urlGenerator->reveal() + ) + ); $this->expectException(Exception::class); $eventListener->onElementPropertyChangeEvent($event); } @@ -54,7 +74,15 @@ public function testUserWithUniqueIdentifyingPropertyTriggersException(): void $emberNexusConfiguration = $this->prophesize(EmberNexusConfiguration::class); $emberNexusConfiguration->getRegisterUniqueIdentifier()->willReturn('email'); $event = new ElementPropertyChangeEvent('User', null, ['email' => true]); - $eventListener = new UserElementPropertyChangeEventListener($emberNexusConfiguration->reveal()); + $urlGenerator = $this->prophesize(UrlGeneratorInterface::class); + $urlGenerator->generate(Argument::cetera()) + ->willReturn('http://example.com/url-to-error'); + $eventListener = new UserElementPropertyChangeEventListener( + $emberNexusConfiguration->reveal(), + new Client400ForbiddenPropertyExceptionFactory( + $urlGenerator->reveal() + ) + ); $this->expectException(Exception::class); $eventListener->onElementPropertyChangeEvent($event); } From c51c1bfeca98146f5609fb1fdbf4d7e46837ad7e Mon Sep 17 00:00:00 2001 From: Syndesi Date: Sun, 27 Aug 2023 22:24:52 +0200 Subject: [PATCH 7/9] Add supervisord to combine all relevant logs and publish to docker logs. --- CHANGELOG.md | 1 + config/packages/monolog.yaml | 4 +- docker/Dockerfile | 11 +-- ...ocker-entrypoint.sh => unit-entrypoint.sh} | 0 docker/supervisord/docker-entrypoint.sh | 7 ++ docker/supervisord/supervisord.conf | 20 ++++ supervisord.log | 98 +++++++++++++++++++ supervisord.pid | 1 + 8 files changed, 134 insertions(+), 8 deletions(-) rename docker/nginx-unit/{docker-entrypoint.sh => unit-entrypoint.sh} (100%) mode change 100755 => 100644 create mode 100644 docker/supervisord/docker-entrypoint.sh create mode 100644 docker/supervisord/supervisord.conf create mode 100644 supervisord.log create mode 100644 supervisord.pid diff --git a/CHANGELOG.md b/CHANGELOG.md index 1d494541..9a42d46d 100755 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## Unreleased ### Added - Add CI workflow to check for upstream Alpine updated. +- Add supervisord to combine all relevant logs and publish to docker logs. ### Changed - Improve documentation. - Change PHP CS ruleset such that global objects are always imported. diff --git a/config/packages/monolog.yaml b/config/packages/monolog.yaml index 40d61c45..8252fe9d 100755 --- a/config/packages/monolog.yaml +++ b/config/packages/monolog.yaml @@ -7,7 +7,7 @@ when@dev: handlers: main: type: stream - path: "%kernel.logs_dir%/%kernel.environment%.log" + path: "%kernel.logs_dir%/log.log" level: debug channels: ["!event"] console: @@ -26,7 +26,7 @@ when@test: channels: ["!event"] nested: type: stream - path: "%kernel.logs_dir%/%kernel.environment%.log" + path: "%kernel.logs_dir%/log.log" level: debug when@prod: diff --git a/docker/Dockerfile b/docker/Dockerfile index 1c08342c..359a9c03 100755 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -290,10 +290,13 @@ COPY --from=nginx_unit_builder /usr/sbin/unitd /usr/sbin/unitd COPY --from=nginx_unit_builder /usr/sbin/unitd-debug /usr/sbin/unitd-debug COPY --from=nginx_unit_builder /usr/lib/unit/ /usr/lib/unit/ COPY --from=nginx_unit_builder /requirements.apt /requirements.apt -COPY ./docker/nginx-unit/docker-entrypoint.sh /usr/local/bin/ +COPY ./docker/nginx-unit/unit-entrypoint.sh /usr/local/bin/ COPY ./docker/nginx-unit/unit.json /docker-entrypoint.d/unit.json +COPY ./docker/supervisord/supervisord.conf /etc/supervisord.conf +COPY ./docker/supervisord/docker-entrypoint.sh /usr/local/bin/ #RUN ldconfig # this command seems to not work on alpine & image works without it? RUN set -x \ + && chmod +x /usr/local/bin/unit-entrypoint.sh \ && chmod +x /usr/local/bin/docker-entrypoint.sh \ && if [ -f "/tmp/libunit.a" ]; then \ mv /tmp/libunit.a /usr/lib/amd64/libunit.a; \ @@ -303,7 +306,7 @@ RUN set -x \ && addgroup --system unit \ && adduser -D -S -G unit unit \ && apk update \ - && apk add curl $(cat /requirements.apt) \ + && apk add curl supervisor $(cat /requirements.apt) \ && rm -f /requirements.apt \ && ln -sf /dev/stdout /var/log/unit.log @@ -311,8 +314,6 @@ STOPSIGNAL SIGTERM ENTRYPOINT ["/usr/local/bin/docker-entrypoint.sh"] -CMD ["unitd", "--no-daemon", "--control", "unix:/var/run/control.unit.sock"] - WORKDIR /var/www/html @@ -348,8 +349,6 @@ STOPSIGNAL SIGTERM ENTRYPOINT ["/usr/local/bin/docker-entrypoint.sh"] -CMD ["unitd", "--no-daemon", "--control", "unix:/var/run/control.unit.sock"] - WORKDIR /var/www/html diff --git a/docker/nginx-unit/docker-entrypoint.sh b/docker/nginx-unit/unit-entrypoint.sh old mode 100755 new mode 100644 similarity index 100% rename from docker/nginx-unit/docker-entrypoint.sh rename to docker/nginx-unit/unit-entrypoint.sh diff --git a/docker/supervisord/docker-entrypoint.sh b/docker/supervisord/docker-entrypoint.sh new file mode 100644 index 00000000..4043eb63 --- /dev/null +++ b/docker/supervisord/docker-entrypoint.sh @@ -0,0 +1,7 @@ +#!/bin/sh + +set -e + +mkdir -p /var/www/html/var/logs +touch /var/www/html/var/logs/log.log +supervisord --nodaemon --configuration /etc/supervisord.conf diff --git a/docker/supervisord/supervisord.conf b/docker/supervisord/supervisord.conf new file mode 100644 index 00000000..5da0d5d2 --- /dev/null +++ b/docker/supervisord/supervisord.conf @@ -0,0 +1,20 @@ +[supervisord] +nodaemon=true +user=root + +[program:nginx-unit] +command=/usr/local/bin/unit-entrypoint.sh unitd --no-daemon --control unix:/var/run/control.unit.sock +directory=/var/www/html +autostart=true +autorestart=true +stdout_logfile=/dev/stdout +redirect_stderr=true +stdout_logfile_maxbytes=0 + +[program:php-logs] +command=tail -f /var/www/html/var/log/log.log +autostart=true +autorestart=true +stdout_logfile=/dev/stdout +redirect_stderr=true +stdout_logfile_maxbytes=0 diff --git a/supervisord.log b/supervisord.log new file mode 100644 index 00000000..ce2ba517 --- /dev/null +++ b/supervisord.log @@ -0,0 +1,98 @@ +2023-08-27 20:09:44,320 CRIT Supervisor is running as root. Privileges were not dropped because no user is specified in the config file. If you intend to run as root, you can set user=root in the config file to avoid this message. +2023-08-27 20:09:44,322 INFO supervisord started with pid 8 +2023-08-27 20:09:45,324 INFO spawned: 'nginx-unit' with pid 9 +2023-08-27 20:09:45,326 INFO spawned: 'php-logs' with pid 10 +2023-08-27 20:09:45,338 CRIT uncaptured python exception, closing channel (stdout)> (:[Errno 29] Invalid seek [/usr/lib/python3.11/site-packages/supervisor/supervisord.py|runforever|218] [/usr/lib/python3.11/site-packages/supervisor/dispatchers.py|handle_read_event|276] [/usr/lib/python3.11/site-packages/supervisor/dispatchers.py|record_output|210] [/usr/lib/python3.11/site-packages/supervisor/dispatchers.py|_log|179] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|info|327] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|log|345] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|emit|227] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|doRollover|264]) +2023-08-27 20:09:45,352 CRIT uncaptured python exception, closing channel (stdout)> (:[Errno 29] Invalid seek [/usr/lib/python3.11/site-packages/supervisor/supervisord.py|runforever|218] [/usr/lib/python3.11/site-packages/supervisor/dispatchers.py|handle_read_event|276] [/usr/lib/python3.11/site-packages/supervisor/dispatchers.py|record_output|210] [/usr/lib/python3.11/site-packages/supervisor/dispatchers.py|_log|179] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|info|327] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|log|345] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|emit|227] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|doRollover|264]) +2023-08-27 20:09:45,358 CRIT uncaptured python exception, closing channel (stdout)> (:[Errno 29] Invalid seek [/usr/lib/python3.11/site-packages/supervisor/supervisord.py|runforever|218] [/usr/lib/python3.11/site-packages/supervisor/dispatchers.py|handle_read_event|276] [/usr/lib/python3.11/site-packages/supervisor/dispatchers.py|record_output|210] [/usr/lib/python3.11/site-packages/supervisor/dispatchers.py|_log|179] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|info|327] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|log|345] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|emit|227] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|doRollover|264]) +2023-08-27 20:09:45,375 CRIT uncaptured python exception, closing channel (stdout)> (:[Errno 29] Invalid seek [/usr/lib/python3.11/site-packages/supervisor/supervisord.py|runforever|218] [/usr/lib/python3.11/site-packages/supervisor/dispatchers.py|handle_read_event|276] [/usr/lib/python3.11/site-packages/supervisor/dispatchers.py|record_output|210] [/usr/lib/python3.11/site-packages/supervisor/dispatchers.py|_log|179] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|info|327] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|log|345] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|emit|227] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|doRollover|264]) +2023-08-27 20:09:45,375 CRIT uncaptured python exception, closing channel (stdout)> (:[Errno 29] Invalid seek [/usr/lib/python3.11/site-packages/supervisor/supervisord.py|runforever|218] [/usr/lib/python3.11/site-packages/supervisor/dispatchers.py|handle_read_event|276] [/usr/lib/python3.11/site-packages/supervisor/dispatchers.py|record_output|210] [/usr/lib/python3.11/site-packages/supervisor/dispatchers.py|_log|179] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|info|327] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|log|345] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|emit|227] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|doRollover|264]) +2023-08-27 20:09:45,378 CRIT uncaptured python exception, closing channel (stdout)> (:[Errno 29] Invalid seek [/usr/lib/python3.11/site-packages/supervisor/supervisord.py|runforever|218] [/usr/lib/python3.11/site-packages/supervisor/dispatchers.py|handle_read_event|276] [/usr/lib/python3.11/site-packages/supervisor/dispatchers.py|record_output|210] [/usr/lib/python3.11/site-packages/supervisor/dispatchers.py|_log|179] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|info|327] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|log|345] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|emit|227] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|doRollover|264]) +2023-08-27 20:09:45,379 CRIT uncaptured python exception, closing channel (stdout)> (:[Errno 29] Invalid seek [/usr/lib/python3.11/site-packages/supervisor/supervisord.py|runforever|218] [/usr/lib/python3.11/site-packages/supervisor/dispatchers.py|handle_read_event|276] [/usr/lib/python3.11/site-packages/supervisor/dispatchers.py|record_output|210] [/usr/lib/python3.11/site-packages/supervisor/dispatchers.py|_log|179] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|info|327] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|log|345] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|emit|227] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|doRollover|264]) +2023-08-27 20:09:45,381 CRIT uncaptured python exception, closing channel (stdout)> (:[Errno 29] Invalid seek [/usr/lib/python3.11/site-packages/supervisor/supervisord.py|runforever|218] [/usr/lib/python3.11/site-packages/supervisor/dispatchers.py|handle_read_event|276] [/usr/lib/python3.11/site-packages/supervisor/dispatchers.py|record_output|210] [/usr/lib/python3.11/site-packages/supervisor/dispatchers.py|_log|179] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|info|327] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|log|345] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|emit|227] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|doRollover|264]) +2023-08-27 20:09:45,386 CRIT uncaptured python exception, closing channel (stdout)> (:[Errno 29] Invalid seek [/usr/lib/python3.11/site-packages/supervisor/supervisord.py|runforever|218] [/usr/lib/python3.11/site-packages/supervisor/dispatchers.py|handle_read_event|276] [/usr/lib/python3.11/site-packages/supervisor/dispatchers.py|record_output|210] [/usr/lib/python3.11/site-packages/supervisor/dispatchers.py|_log|179] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|info|327] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|log|345] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|emit|227] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|doRollover|264]) +2023-08-27 20:09:45,389 CRIT uncaptured python exception, closing channel (stdout)> (:[Errno 29] Invalid seek [/usr/lib/python3.11/site-packages/supervisor/supervisord.py|runforever|218] [/usr/lib/python3.11/site-packages/supervisor/dispatchers.py|handle_read_event|276] [/usr/lib/python3.11/site-packages/supervisor/dispatchers.py|record_output|210] [/usr/lib/python3.11/site-packages/supervisor/dispatchers.py|_log|179] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|info|327] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|log|345] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|emit|227] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|doRollover|264]) +2023-08-27 20:09:45,389 CRIT uncaptured python exception, closing channel (stdout)> (:[Errno 29] Invalid seek [/usr/lib/python3.11/site-packages/supervisor/supervisord.py|runforever|218] [/usr/lib/python3.11/site-packages/supervisor/dispatchers.py|handle_read_event|276] [/usr/lib/python3.11/site-packages/supervisor/dispatchers.py|record_output|210] [/usr/lib/python3.11/site-packages/supervisor/dispatchers.py|_log|179] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|info|327] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|log|345] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|emit|227] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|doRollover|264]) +2023-08-27 20:09:45,440 CRIT uncaptured python exception, closing channel (stdout)> (:[Errno 29] Invalid seek [/usr/lib/python3.11/site-packages/supervisor/supervisord.py|runforever|218] [/usr/lib/python3.11/site-packages/supervisor/dispatchers.py|handle_read_event|276] [/usr/lib/python3.11/site-packages/supervisor/dispatchers.py|record_output|210] [/usr/lib/python3.11/site-packages/supervisor/dispatchers.py|_log|179] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|info|327] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|log|345] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|emit|227] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|doRollover|264]) +2023-08-27 20:09:45,445 CRIT uncaptured python exception, closing channel (stdout)> (:[Errno 29] Invalid seek [/usr/lib/python3.11/site-packages/supervisor/supervisord.py|runforever|218] [/usr/lib/python3.11/site-packages/supervisor/dispatchers.py|handle_read_event|276] [/usr/lib/python3.11/site-packages/supervisor/dispatchers.py|record_output|210] [/usr/lib/python3.11/site-packages/supervisor/dispatchers.py|_log|179] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|info|327] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|log|345] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|emit|227] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|doRollover|264]) +2023-08-27 20:09:45,455 CRIT uncaptured python exception, closing channel (stdout)> (:[Errno 29] Invalid seek [/usr/lib/python3.11/site-packages/supervisor/supervisord.py|runforever|218] [/usr/lib/python3.11/site-packages/supervisor/dispatchers.py|handle_read_event|276] [/usr/lib/python3.11/site-packages/supervisor/dispatchers.py|record_output|210] [/usr/lib/python3.11/site-packages/supervisor/dispatchers.py|_log|179] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|info|327] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|log|345] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|emit|227] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|doRollover|264]) +2023-08-27 20:09:45,462 CRIT uncaptured python exception, closing channel (stdout)> (:[Errno 29] Invalid seek [/usr/lib/python3.11/site-packages/supervisor/supervisord.py|runforever|218] [/usr/lib/python3.11/site-packages/supervisor/dispatchers.py|handle_read_event|276] [/usr/lib/python3.11/site-packages/supervisor/dispatchers.py|record_output|210] [/usr/lib/python3.11/site-packages/supervisor/dispatchers.py|_log|179] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|info|327] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|log|345] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|emit|227] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|doRollover|264]) +2023-08-27 20:09:45,467 CRIT uncaptured python exception, closing channel (stdout)> (:[Errno 29] Invalid seek [/usr/lib/python3.11/site-packages/supervisor/supervisord.py|runforever|218] [/usr/lib/python3.11/site-packages/supervisor/dispatchers.py|handle_read_event|276] [/usr/lib/python3.11/site-packages/supervisor/dispatchers.py|record_output|210] [/usr/lib/python3.11/site-packages/supervisor/dispatchers.py|_log|179] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|info|327] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|log|345] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|emit|227] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|doRollover|264]) +2023-08-27 20:09:45,467 CRIT uncaptured python exception, closing channel (stdout)> (:[Errno 29] Invalid seek [/usr/lib/python3.11/site-packages/supervisor/supervisord.py|runforever|218] [/usr/lib/python3.11/site-packages/supervisor/dispatchers.py|handle_read_event|276] [/usr/lib/python3.11/site-packages/supervisor/dispatchers.py|record_output|210] [/usr/lib/python3.11/site-packages/supervisor/dispatchers.py|_log|179] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|info|327] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|log|345] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|emit|227] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|doRollover|264]) +2023-08-27 20:09:45,468 CRIT uncaptured python exception, closing channel (stdout)> (:[Errno 29] Invalid seek [/usr/lib/python3.11/site-packages/supervisor/supervisord.py|runforever|218] [/usr/lib/python3.11/site-packages/supervisor/dispatchers.py|handle_read_event|276] [/usr/lib/python3.11/site-packages/supervisor/dispatchers.py|record_output|210] [/usr/lib/python3.11/site-packages/supervisor/dispatchers.py|_log|179] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|info|327] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|log|345] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|emit|227] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|doRollover|264]) +2023-08-27 20:09:45,469 CRIT uncaptured python exception, closing channel (stdout)> (:[Errno 29] Invalid seek [/usr/lib/python3.11/site-packages/supervisor/supervisord.py|runforever|218] [/usr/lib/python3.11/site-packages/supervisor/dispatchers.py|handle_read_event|276] [/usr/lib/python3.11/site-packages/supervisor/dispatchers.py|record_output|210] [/usr/lib/python3.11/site-packages/supervisor/dispatchers.py|_log|179] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|info|327] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|log|345] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|emit|227] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|doRollover|264]) +2023-08-27 20:09:45,471 CRIT uncaptured python exception, closing channel (stdout)> (:[Errno 29] Invalid seek [/usr/lib/python3.11/site-packages/supervisor/supervisord.py|runforever|218] [/usr/lib/python3.11/site-packages/supervisor/dispatchers.py|handle_read_event|276] [/usr/lib/python3.11/site-packages/supervisor/dispatchers.py|record_output|210] [/usr/lib/python3.11/site-packages/supervisor/dispatchers.py|_log|179] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|info|327] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|log|345] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|emit|227] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|doRollover|264]) +2023-08-27 20:09:46,475 CRIT uncaptured python exception, closing channel (stdout)> (:[Errno 29] Invalid seek [/usr/lib/python3.11/site-packages/supervisor/supervisord.py|runforever|218] [/usr/lib/python3.11/site-packages/supervisor/dispatchers.py|handle_read_event|276] [/usr/lib/python3.11/site-packages/supervisor/dispatchers.py|record_output|210] [/usr/lib/python3.11/site-packages/supervisor/dispatchers.py|_log|179] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|info|327] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|log|345] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|emit|227] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|doRollover|264]) +2023-08-27 20:09:46,476 INFO success: nginx-unit entered RUNNING state, process has stayed up for > than 1 seconds (startsecs) +2023-08-27 20:09:46,476 INFO success: php-logs entered RUNNING state, process has stayed up for > than 1 seconds (startsecs) +2023-08-27 20:09:46,484 CRIT uncaptured python exception, closing channel (stdout)> (:[Errno 29] Invalid seek [/usr/lib/python3.11/site-packages/supervisor/supervisord.py|runforever|218] [/usr/lib/python3.11/site-packages/supervisor/dispatchers.py|handle_read_event|276] [/usr/lib/python3.11/site-packages/supervisor/dispatchers.py|record_output|210] [/usr/lib/python3.11/site-packages/supervisor/dispatchers.py|_log|179] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|info|327] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|log|345] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|emit|227] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|doRollover|264]) +2023-08-27 20:09:46,485 CRIT uncaptured python exception, closing channel (stdout)> (:[Errno 29] Invalid seek [/usr/lib/python3.11/site-packages/supervisor/supervisord.py|runforever|218] [/usr/lib/python3.11/site-packages/supervisor/dispatchers.py|handle_read_event|276] [/usr/lib/python3.11/site-packages/supervisor/dispatchers.py|record_output|210] [/usr/lib/python3.11/site-packages/supervisor/dispatchers.py|_log|179] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|info|327] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|log|345] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|emit|227] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|doRollover|264]) +2023-08-27 20:09:46,491 CRIT uncaptured python exception, closing channel (stdout)> (:[Errno 29] Invalid seek [/usr/lib/python3.11/site-packages/supervisor/supervisord.py|runforever|218] [/usr/lib/python3.11/site-packages/supervisor/dispatchers.py|handle_read_event|276] [/usr/lib/python3.11/site-packages/supervisor/dispatchers.py|record_output|210] [/usr/lib/python3.11/site-packages/supervisor/dispatchers.py|_log|179] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|info|327] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|log|345] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|emit|227] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|doRollover|264]) +2023-08-27 20:09:46,491 CRIT uncaptured python exception, closing channel (stdout)> (:[Errno 29] Invalid seek [/usr/lib/python3.11/site-packages/supervisor/supervisord.py|runforever|218] [/usr/lib/python3.11/site-packages/supervisor/dispatchers.py|handle_read_event|276] [/usr/lib/python3.11/site-packages/supervisor/dispatchers.py|record_output|210] [/usr/lib/python3.11/site-packages/supervisor/dispatchers.py|_log|179] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|info|327] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|log|345] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|emit|227] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|doRollover|264]) +2023-08-27 20:09:46,492 CRIT uncaptured python exception, closing channel (stdout)> (:[Errno 29] Invalid seek [/usr/lib/python3.11/site-packages/supervisor/supervisord.py|runforever|218] [/usr/lib/python3.11/site-packages/supervisor/dispatchers.py|handle_read_event|276] [/usr/lib/python3.11/site-packages/supervisor/dispatchers.py|record_output|210] [/usr/lib/python3.11/site-packages/supervisor/dispatchers.py|_log|179] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|info|327] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|log|345] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|emit|227] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|doRollover|264]) +2023-08-27 20:09:46,492 CRIT uncaptured python exception, closing channel (stdout)> (:[Errno 29] Invalid seek [/usr/lib/python3.11/site-packages/supervisor/supervisord.py|runforever|218] [/usr/lib/python3.11/site-packages/supervisor/dispatchers.py|handle_read_event|276] [/usr/lib/python3.11/site-packages/supervisor/dispatchers.py|record_output|210] [/usr/lib/python3.11/site-packages/supervisor/dispatchers.py|_log|179] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|info|327] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|log|345] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|emit|227] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|doRollover|264]) +2023-08-27 20:09:46,510 CRIT uncaptured python exception, closing channel (stdout)> (:[Errno 29] Invalid seek [/usr/lib/python3.11/site-packages/supervisor/supervisord.py|runforever|218] [/usr/lib/python3.11/site-packages/supervisor/dispatchers.py|handle_read_event|276] [/usr/lib/python3.11/site-packages/supervisor/dispatchers.py|record_output|210] [/usr/lib/python3.11/site-packages/supervisor/dispatchers.py|_log|179] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|info|327] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|log|345] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|emit|227] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|doRollover|264]) +2023-08-27 20:09:46,579 CRIT uncaptured python exception, closing channel (stdout)> (:[Errno 29] Invalid seek [/usr/lib/python3.11/site-packages/supervisor/supervisord.py|runforever|218] [/usr/lib/python3.11/site-packages/supervisor/dispatchers.py|handle_read_event|276] [/usr/lib/python3.11/site-packages/supervisor/dispatchers.py|record_output|210] [/usr/lib/python3.11/site-packages/supervisor/dispatchers.py|_log|179] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|info|327] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|log|345] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|emit|227] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|doRollover|264]) +2023-08-27 20:09:46,581 CRIT uncaptured python exception, closing channel (stdout)> (:[Errno 29] Invalid seek [/usr/lib/python3.11/site-packages/supervisor/supervisord.py|runforever|218] [/usr/lib/python3.11/site-packages/supervisor/dispatchers.py|handle_read_event|276] [/usr/lib/python3.11/site-packages/supervisor/dispatchers.py|record_output|210] [/usr/lib/python3.11/site-packages/supervisor/dispatchers.py|_log|179] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|info|327] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|log|345] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|emit|227] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|doRollover|264]) +2023-08-27 20:10:48,797 CRIT Supervisor is running as root. Privileges were not dropped because no user is specified in the config file. If you intend to run as root, you can set user=root in the config file to avoid this message. +2023-08-27 20:10:48,801 INFO supervisord started with pid 10 +2023-08-27 20:10:49,803 INFO spawned: 'nginx-unit' with pid 11 +2023-08-27 20:10:49,806 INFO spawned: 'php-logs' with pid 12 +2023-08-27 20:10:49,810 CRIT uncaptured python exception, closing channel (stdout)> (:[Errno 29] Invalid seek [/usr/lib/python3.11/site-packages/supervisor/supervisord.py|runforever|218] [/usr/lib/python3.11/site-packages/supervisor/dispatchers.py|handle_read_event|276] [/usr/lib/python3.11/site-packages/supervisor/dispatchers.py|record_output|210] [/usr/lib/python3.11/site-packages/supervisor/dispatchers.py|_log|179] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|info|327] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|log|345] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|emit|227] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|doRollover|264]) +2023-08-27 20:10:49,822 CRIT uncaptured python exception, closing channel (stdout)> (:[Errno 29] Invalid seek [/usr/lib/python3.11/site-packages/supervisor/supervisord.py|runforever|218] [/usr/lib/python3.11/site-packages/supervisor/dispatchers.py|handle_read_event|276] [/usr/lib/python3.11/site-packages/supervisor/dispatchers.py|record_output|210] [/usr/lib/python3.11/site-packages/supervisor/dispatchers.py|_log|179] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|info|327] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|log|345] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|emit|227] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|doRollover|264]) +2023-08-27 20:10:49,823 CRIT uncaptured python exception, closing channel (stdout)> (:[Errno 29] Invalid seek [/usr/lib/python3.11/site-packages/supervisor/supervisord.py|runforever|218] [/usr/lib/python3.11/site-packages/supervisor/dispatchers.py|handle_read_event|276] [/usr/lib/python3.11/site-packages/supervisor/dispatchers.py|record_output|210] [/usr/lib/python3.11/site-packages/supervisor/dispatchers.py|_log|179] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|info|327] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|log|345] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|emit|227] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|doRollover|264]) +2023-08-27 20:10:49,841 CRIT uncaptured python exception, closing channel (stdout)> (:[Errno 29] Invalid seek [/usr/lib/python3.11/site-packages/supervisor/supervisord.py|runforever|218] [/usr/lib/python3.11/site-packages/supervisor/dispatchers.py|handle_read_event|276] [/usr/lib/python3.11/site-packages/supervisor/dispatchers.py|record_output|210] [/usr/lib/python3.11/site-packages/supervisor/dispatchers.py|_log|179] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|info|327] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|log|345] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|emit|227] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|doRollover|264]) +2023-08-27 20:10:49,842 CRIT uncaptured python exception, closing channel (stdout)> (:[Errno 29] Invalid seek [/usr/lib/python3.11/site-packages/supervisor/supervisord.py|runforever|218] [/usr/lib/python3.11/site-packages/supervisor/dispatchers.py|handle_read_event|276] [/usr/lib/python3.11/site-packages/supervisor/dispatchers.py|record_output|210] [/usr/lib/python3.11/site-packages/supervisor/dispatchers.py|_log|179] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|info|327] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|log|345] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|emit|227] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|doRollover|264]) +2023-08-27 20:10:49,843 CRIT uncaptured python exception, closing channel (stdout)> (:[Errno 29] Invalid seek [/usr/lib/python3.11/site-packages/supervisor/supervisord.py|runforever|218] [/usr/lib/python3.11/site-packages/supervisor/dispatchers.py|handle_read_event|276] [/usr/lib/python3.11/site-packages/supervisor/dispatchers.py|record_output|210] [/usr/lib/python3.11/site-packages/supervisor/dispatchers.py|_log|179] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|info|327] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|log|345] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|emit|227] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|doRollover|264]) +2023-08-27 20:10:49,844 CRIT uncaptured python exception, closing channel (stdout)> (:[Errno 29] Invalid seek [/usr/lib/python3.11/site-packages/supervisor/supervisord.py|runforever|218] [/usr/lib/python3.11/site-packages/supervisor/dispatchers.py|handle_read_event|276] [/usr/lib/python3.11/site-packages/supervisor/dispatchers.py|record_output|210] [/usr/lib/python3.11/site-packages/supervisor/dispatchers.py|_log|179] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|info|327] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|log|345] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|emit|227] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|doRollover|264]) +2023-08-27 20:10:49,845 CRIT uncaptured python exception, closing channel (stdout)> (:[Errno 29] Invalid seek [/usr/lib/python3.11/site-packages/supervisor/supervisord.py|runforever|218] [/usr/lib/python3.11/site-packages/supervisor/dispatchers.py|handle_read_event|276] [/usr/lib/python3.11/site-packages/supervisor/dispatchers.py|record_output|210] [/usr/lib/python3.11/site-packages/supervisor/dispatchers.py|_log|179] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|info|327] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|log|345] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|emit|227] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|doRollover|264]) +2023-08-27 20:10:49,906 CRIT uncaptured python exception, closing channel (stdout)> (:[Errno 29] Invalid seek [/usr/lib/python3.11/site-packages/supervisor/supervisord.py|runforever|218] [/usr/lib/python3.11/site-packages/supervisor/dispatchers.py|handle_read_event|276] [/usr/lib/python3.11/site-packages/supervisor/dispatchers.py|record_output|210] [/usr/lib/python3.11/site-packages/supervisor/dispatchers.py|_log|179] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|info|327] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|log|345] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|emit|227] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|doRollover|264]) +2023-08-27 20:10:49,909 CRIT uncaptured python exception, closing channel (stdout)> (:[Errno 29] Invalid seek [/usr/lib/python3.11/site-packages/supervisor/supervisord.py|runforever|218] [/usr/lib/python3.11/site-packages/supervisor/dispatchers.py|handle_read_event|276] [/usr/lib/python3.11/site-packages/supervisor/dispatchers.py|record_output|210] [/usr/lib/python3.11/site-packages/supervisor/dispatchers.py|_log|179] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|info|327] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|log|345] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|emit|227] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|doRollover|264]) +2023-08-27 20:10:50,910 INFO success: nginx-unit entered RUNNING state, process has stayed up for > than 1 seconds (startsecs) +2023-08-27 20:10:50,911 INFO success: php-logs entered RUNNING state, process has stayed up for > than 1 seconds (startsecs) +2023-08-27 20:11:45,817 CRIT uncaptured python exception, closing channel (stdout)> (:[Errno 29] Invalid seek [/usr/lib/python3.11/site-packages/supervisor/supervisord.py|runforever|218] [/usr/lib/python3.11/site-packages/supervisor/dispatchers.py|handle_read_event|276] [/usr/lib/python3.11/site-packages/supervisor/dispatchers.py|record_output|210] [/usr/lib/python3.11/site-packages/supervisor/dispatchers.py|_log|179] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|info|327] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|log|345] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|emit|227] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|doRollover|264]) +2023-08-27 20:12:12,820 CRIT uncaptured python exception, closing channel (stdout)> (:[Errno 29] Invalid seek [/usr/lib/python3.11/site-packages/supervisor/supervisord.py|runforever|218] [/usr/lib/python3.11/site-packages/supervisor/dispatchers.py|handle_read_event|276] [/usr/lib/python3.11/site-packages/supervisor/dispatchers.py|record_output|210] [/usr/lib/python3.11/site-packages/supervisor/dispatchers.py|_log|179] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|info|327] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|log|345] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|emit|227] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|doRollover|264]) +2023-08-27 20:16:14,778 INFO Set uid to user 0 succeeded +2023-08-27 20:16:14,780 INFO supervisord started with pid 9 +2023-08-27 20:16:15,782 INFO spawned: 'nginx-unit' with pid 10 +2023-08-27 20:16:15,784 INFO spawned: 'php-logs' with pid 11 +2023-08-27 20:16:15,789 CRIT uncaptured python exception, closing channel (stdout)> (:[Errno 29] Invalid seek [/usr/lib/python3.11/site-packages/supervisor/supervisord.py|runforever|218] [/usr/lib/python3.11/site-packages/supervisor/dispatchers.py|handle_read_event|276] [/usr/lib/python3.11/site-packages/supervisor/dispatchers.py|record_output|210] [/usr/lib/python3.11/site-packages/supervisor/dispatchers.py|_log|179] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|info|327] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|log|345] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|emit|227] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|doRollover|264]) +2023-08-27 20:16:15,829 CRIT uncaptured python exception, closing channel (stdout)> (:[Errno 29] Invalid seek [/usr/lib/python3.11/site-packages/supervisor/supervisord.py|runforever|218] [/usr/lib/python3.11/site-packages/supervisor/dispatchers.py|handle_read_event|276] [/usr/lib/python3.11/site-packages/supervisor/dispatchers.py|record_output|210] [/usr/lib/python3.11/site-packages/supervisor/dispatchers.py|_log|179] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|info|327] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|log|345] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|emit|227] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|doRollover|264]) +2023-08-27 20:16:15,830 CRIT uncaptured python exception, closing channel (stdout)> (:[Errno 29] Invalid seek [/usr/lib/python3.11/site-packages/supervisor/supervisord.py|runforever|218] [/usr/lib/python3.11/site-packages/supervisor/dispatchers.py|handle_read_event|276] [/usr/lib/python3.11/site-packages/supervisor/dispatchers.py|record_output|210] [/usr/lib/python3.11/site-packages/supervisor/dispatchers.py|_log|179] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|info|327] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|log|345] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|emit|227] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|doRollover|264]) +2023-08-27 20:16:15,862 CRIT uncaptured python exception, closing channel (stdout)> (:[Errno 29] Invalid seek [/usr/lib/python3.11/site-packages/supervisor/supervisord.py|runforever|218] [/usr/lib/python3.11/site-packages/supervisor/dispatchers.py|handle_read_event|276] [/usr/lib/python3.11/site-packages/supervisor/dispatchers.py|record_output|210] [/usr/lib/python3.11/site-packages/supervisor/dispatchers.py|_log|179] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|info|327] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|log|345] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|emit|227] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|doRollover|264]) +2023-08-27 20:16:15,867 CRIT uncaptured python exception, closing channel (stdout)> (:[Errno 29] Invalid seek [/usr/lib/python3.11/site-packages/supervisor/supervisord.py|runforever|218] [/usr/lib/python3.11/site-packages/supervisor/dispatchers.py|handle_read_event|276] [/usr/lib/python3.11/site-packages/supervisor/dispatchers.py|record_output|210] [/usr/lib/python3.11/site-packages/supervisor/dispatchers.py|_log|179] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|info|327] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|log|345] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|emit|227] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|doRollover|264]) +2023-08-27 20:16:15,867 CRIT uncaptured python exception, closing channel (stdout)> (:[Errno 29] Invalid seek [/usr/lib/python3.11/site-packages/supervisor/supervisord.py|runforever|218] [/usr/lib/python3.11/site-packages/supervisor/dispatchers.py|handle_read_event|276] [/usr/lib/python3.11/site-packages/supervisor/dispatchers.py|record_output|210] [/usr/lib/python3.11/site-packages/supervisor/dispatchers.py|_log|179] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|info|327] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|log|345] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|emit|227] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|doRollover|264]) +2023-08-27 20:16:15,868 CRIT uncaptured python exception, closing channel (stdout)> (:[Errno 29] Invalid seek [/usr/lib/python3.11/site-packages/supervisor/supervisord.py|runforever|218] [/usr/lib/python3.11/site-packages/supervisor/dispatchers.py|handle_read_event|276] [/usr/lib/python3.11/site-packages/supervisor/dispatchers.py|record_output|210] [/usr/lib/python3.11/site-packages/supervisor/dispatchers.py|_log|179] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|info|327] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|log|345] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|emit|227] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|doRollover|264]) +2023-08-27 20:16:15,868 CRIT uncaptured python exception, closing channel (stdout)> (:[Errno 29] Invalid seek [/usr/lib/python3.11/site-packages/supervisor/supervisord.py|runforever|218] [/usr/lib/python3.11/site-packages/supervisor/dispatchers.py|handle_read_event|276] [/usr/lib/python3.11/site-packages/supervisor/dispatchers.py|record_output|210] [/usr/lib/python3.11/site-packages/supervisor/dispatchers.py|_log|179] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|info|327] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|log|345] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|emit|227] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|doRollover|264]) +2023-08-27 20:16:15,871 CRIT uncaptured python exception, closing channel (stdout)> (:[Errno 29] Invalid seek [/usr/lib/python3.11/site-packages/supervisor/supervisord.py|runforever|218] [/usr/lib/python3.11/site-packages/supervisor/dispatchers.py|handle_read_event|276] [/usr/lib/python3.11/site-packages/supervisor/dispatchers.py|record_output|210] [/usr/lib/python3.11/site-packages/supervisor/dispatchers.py|_log|179] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|info|327] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|log|345] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|emit|227] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|doRollover|264]) +2023-08-27 20:16:15,872 CRIT uncaptured python exception, closing channel (stdout)> (:[Errno 29] Invalid seek [/usr/lib/python3.11/site-packages/supervisor/supervisord.py|runforever|218] [/usr/lib/python3.11/site-packages/supervisor/dispatchers.py|handle_read_event|276] [/usr/lib/python3.11/site-packages/supervisor/dispatchers.py|record_output|210] [/usr/lib/python3.11/site-packages/supervisor/dispatchers.py|_log|179] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|info|327] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|log|345] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|emit|227] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|doRollover|264]) +2023-08-27 20:16:15,893 CRIT uncaptured python exception, closing channel (stdout)> (:[Errno 29] Invalid seek [/usr/lib/python3.11/site-packages/supervisor/supervisord.py|runforever|218] [/usr/lib/python3.11/site-packages/supervisor/dispatchers.py|handle_read_event|276] [/usr/lib/python3.11/site-packages/supervisor/dispatchers.py|record_output|210] [/usr/lib/python3.11/site-packages/supervisor/dispatchers.py|_log|179] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|info|327] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|log|345] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|emit|227] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|doRollover|264]) +2023-08-27 20:16:15,900 CRIT uncaptured python exception, closing channel (stdout)> (:[Errno 29] Invalid seek [/usr/lib/python3.11/site-packages/supervisor/supervisord.py|runforever|218] [/usr/lib/python3.11/site-packages/supervisor/dispatchers.py|handle_read_event|276] [/usr/lib/python3.11/site-packages/supervisor/dispatchers.py|record_output|210] [/usr/lib/python3.11/site-packages/supervisor/dispatchers.py|_log|179] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|info|327] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|log|345] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|emit|227] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|doRollover|264]) +2023-08-27 20:16:15,970 CRIT uncaptured python exception, closing channel (stdout)> (:[Errno 29] Invalid seek [/usr/lib/python3.11/site-packages/supervisor/supervisord.py|runforever|218] [/usr/lib/python3.11/site-packages/supervisor/dispatchers.py|handle_read_event|276] [/usr/lib/python3.11/site-packages/supervisor/dispatchers.py|record_output|210] [/usr/lib/python3.11/site-packages/supervisor/dispatchers.py|_log|179] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|info|327] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|log|345] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|emit|227] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|doRollover|264]) +2023-08-27 20:16:15,973 CRIT uncaptured python exception, closing channel (stdout)> (:[Errno 29] Invalid seek [/usr/lib/python3.11/site-packages/supervisor/supervisord.py|runforever|218] [/usr/lib/python3.11/site-packages/supervisor/dispatchers.py|handle_read_event|276] [/usr/lib/python3.11/site-packages/supervisor/dispatchers.py|record_output|210] [/usr/lib/python3.11/site-packages/supervisor/dispatchers.py|_log|179] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|info|327] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|log|345] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|emit|227] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|doRollover|264]) +2023-08-27 20:16:16,005 CRIT uncaptured python exception, closing channel (stdout)> (:[Errno 29] Invalid seek [/usr/lib/python3.11/site-packages/supervisor/supervisord.py|runforever|218] [/usr/lib/python3.11/site-packages/supervisor/dispatchers.py|handle_read_event|276] [/usr/lib/python3.11/site-packages/supervisor/dispatchers.py|record_output|210] [/usr/lib/python3.11/site-packages/supervisor/dispatchers.py|_log|179] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|info|327] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|log|345] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|emit|227] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|doRollover|264]) +2023-08-27 20:16:16,006 CRIT uncaptured python exception, closing channel (stdout)> (:[Errno 29] Invalid seek [/usr/lib/python3.11/site-packages/supervisor/supervisord.py|runforever|218] [/usr/lib/python3.11/site-packages/supervisor/dispatchers.py|handle_read_event|276] [/usr/lib/python3.11/site-packages/supervisor/dispatchers.py|record_output|210] [/usr/lib/python3.11/site-packages/supervisor/dispatchers.py|_log|179] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|info|327] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|log|345] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|emit|227] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|doRollover|264]) +2023-08-27 20:16:16,016 CRIT uncaptured python exception, closing channel (stdout)> (:[Errno 29] Invalid seek [/usr/lib/python3.11/site-packages/supervisor/supervisord.py|runforever|218] [/usr/lib/python3.11/site-packages/supervisor/dispatchers.py|handle_read_event|276] [/usr/lib/python3.11/site-packages/supervisor/dispatchers.py|record_output|210] [/usr/lib/python3.11/site-packages/supervisor/dispatchers.py|_log|179] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|info|327] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|log|345] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|emit|227] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|doRollover|264]) +2023-08-27 20:16:16,018 CRIT uncaptured python exception, closing channel (stdout)> (:[Errno 29] Invalid seek [/usr/lib/python3.11/site-packages/supervisor/supervisord.py|runforever|218] [/usr/lib/python3.11/site-packages/supervisor/dispatchers.py|handle_read_event|276] [/usr/lib/python3.11/site-packages/supervisor/dispatchers.py|record_output|210] [/usr/lib/python3.11/site-packages/supervisor/dispatchers.py|_log|179] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|info|327] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|log|345] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|emit|227] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|doRollover|264]) +2023-08-27 20:16:16,018 CRIT uncaptured python exception, closing channel (stdout)> (:[Errno 29] Invalid seek [/usr/lib/python3.11/site-packages/supervisor/supervisord.py|runforever|218] [/usr/lib/python3.11/site-packages/supervisor/dispatchers.py|handle_read_event|276] [/usr/lib/python3.11/site-packages/supervisor/dispatchers.py|record_output|210] [/usr/lib/python3.11/site-packages/supervisor/dispatchers.py|_log|179] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|info|327] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|log|345] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|emit|227] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|doRollover|264]) +2023-08-27 20:16:16,018 CRIT uncaptured python exception, closing channel (stdout)> (:[Errno 29] Invalid seek [/usr/lib/python3.11/site-packages/supervisor/supervisord.py|runforever|218] [/usr/lib/python3.11/site-packages/supervisor/dispatchers.py|handle_read_event|276] [/usr/lib/python3.11/site-packages/supervisor/dispatchers.py|record_output|210] [/usr/lib/python3.11/site-packages/supervisor/dispatchers.py|_log|179] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|info|327] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|log|345] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|emit|227] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|doRollover|264]) +2023-08-27 20:16:16,021 CRIT uncaptured python exception, closing channel (stdout)> (:[Errno 29] Invalid seek [/usr/lib/python3.11/site-packages/supervisor/supervisord.py|runforever|218] [/usr/lib/python3.11/site-packages/supervisor/dispatchers.py|handle_read_event|276] [/usr/lib/python3.11/site-packages/supervisor/dispatchers.py|record_output|210] [/usr/lib/python3.11/site-packages/supervisor/dispatchers.py|_log|179] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|info|327] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|log|345] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|emit|227] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|doRollover|264]) +2023-08-27 20:16:16,023 CRIT uncaptured python exception, closing channel (stdout)> (:[Errno 29] Invalid seek [/usr/lib/python3.11/site-packages/supervisor/supervisord.py|runforever|218] [/usr/lib/python3.11/site-packages/supervisor/dispatchers.py|handle_read_event|276] [/usr/lib/python3.11/site-packages/supervisor/dispatchers.py|record_output|210] [/usr/lib/python3.11/site-packages/supervisor/dispatchers.py|_log|179] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|info|327] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|log|345] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|emit|227] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|doRollover|264]) +2023-08-27 20:16:17,020 CRIT uncaptured python exception, closing channel (stdout)> (:[Errno 29] Invalid seek [/usr/lib/python3.11/site-packages/supervisor/supervisord.py|runforever|218] [/usr/lib/python3.11/site-packages/supervisor/dispatchers.py|handle_read_event|276] [/usr/lib/python3.11/site-packages/supervisor/dispatchers.py|record_output|210] [/usr/lib/python3.11/site-packages/supervisor/dispatchers.py|_log|179] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|info|327] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|log|345] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|emit|227] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|doRollover|264]) +2023-08-27 20:16:17,020 INFO success: nginx-unit entered RUNNING state, process has stayed up for > than 1 seconds (startsecs) +2023-08-27 20:16:17,020 INFO success: php-logs entered RUNNING state, process has stayed up for > than 1 seconds (startsecs) +2023-08-27 20:16:17,030 CRIT uncaptured python exception, closing channel (stdout)> (:[Errno 29] Invalid seek [/usr/lib/python3.11/site-packages/supervisor/supervisord.py|runforever|218] [/usr/lib/python3.11/site-packages/supervisor/dispatchers.py|handle_read_event|276] [/usr/lib/python3.11/site-packages/supervisor/dispatchers.py|record_output|210] [/usr/lib/python3.11/site-packages/supervisor/dispatchers.py|_log|179] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|info|327] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|log|345] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|emit|227] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|doRollover|264]) +2023-08-27 20:16:17,031 CRIT uncaptured python exception, closing channel (stdout)> (:[Errno 29] Invalid seek [/usr/lib/python3.11/site-packages/supervisor/supervisord.py|runforever|218] [/usr/lib/python3.11/site-packages/supervisor/dispatchers.py|handle_read_event|276] [/usr/lib/python3.11/site-packages/supervisor/dispatchers.py|record_output|210] [/usr/lib/python3.11/site-packages/supervisor/dispatchers.py|_log|179] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|info|327] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|log|345] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|emit|227] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|doRollover|264]) +2023-08-27 20:16:17,036 CRIT uncaptured python exception, closing channel (stdout)> (:[Errno 29] Invalid seek [/usr/lib/python3.11/site-packages/supervisor/supervisord.py|runforever|218] [/usr/lib/python3.11/site-packages/supervisor/dispatchers.py|handle_read_event|276] [/usr/lib/python3.11/site-packages/supervisor/dispatchers.py|record_output|210] [/usr/lib/python3.11/site-packages/supervisor/dispatchers.py|_log|179] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|info|327] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|log|345] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|emit|227] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|doRollover|264]) +2023-08-27 20:16:17,037 CRIT uncaptured python exception, closing channel (stdout)> (:[Errno 29] Invalid seek [/usr/lib/python3.11/site-packages/supervisor/supervisord.py|runforever|218] [/usr/lib/python3.11/site-packages/supervisor/dispatchers.py|handle_read_event|276] [/usr/lib/python3.11/site-packages/supervisor/dispatchers.py|record_output|210] [/usr/lib/python3.11/site-packages/supervisor/dispatchers.py|_log|179] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|info|327] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|log|345] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|emit|227] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|doRollover|264]) +2023-08-27 20:16:17,039 CRIT uncaptured python exception, closing channel (stdout)> (:[Errno 29] Invalid seek [/usr/lib/python3.11/site-packages/supervisor/supervisord.py|runforever|218] [/usr/lib/python3.11/site-packages/supervisor/dispatchers.py|handle_read_event|276] [/usr/lib/python3.11/site-packages/supervisor/dispatchers.py|record_output|210] [/usr/lib/python3.11/site-packages/supervisor/dispatchers.py|_log|179] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|info|327] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|log|345] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|emit|227] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|doRollover|264]) +2023-08-27 20:16:17,039 CRIT uncaptured python exception, closing channel (stdout)> (:[Errno 29] Invalid seek [/usr/lib/python3.11/site-packages/supervisor/supervisord.py|runforever|218] [/usr/lib/python3.11/site-packages/supervisor/dispatchers.py|handle_read_event|276] [/usr/lib/python3.11/site-packages/supervisor/dispatchers.py|record_output|210] [/usr/lib/python3.11/site-packages/supervisor/dispatchers.py|_log|179] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|info|327] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|log|345] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|emit|227] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|doRollover|264]) +2023-08-27 20:16:17,041 CRIT uncaptured python exception, closing channel (stdout)> (:[Errno 29] Invalid seek [/usr/lib/python3.11/site-packages/supervisor/supervisord.py|runforever|218] [/usr/lib/python3.11/site-packages/supervisor/dispatchers.py|handle_read_event|276] [/usr/lib/python3.11/site-packages/supervisor/dispatchers.py|record_output|210] [/usr/lib/python3.11/site-packages/supervisor/dispatchers.py|_log|179] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|info|327] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|log|345] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|emit|227] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|doRollover|264]) +2023-08-27 20:16:17,177 CRIT uncaptured python exception, closing channel (stdout)> (:[Errno 29] Invalid seek [/usr/lib/python3.11/site-packages/supervisor/supervisord.py|runforever|218] [/usr/lib/python3.11/site-packages/supervisor/dispatchers.py|handle_read_event|276] [/usr/lib/python3.11/site-packages/supervisor/dispatchers.py|record_output|210] [/usr/lib/python3.11/site-packages/supervisor/dispatchers.py|_log|179] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|info|327] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|log|345] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|emit|227] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|doRollover|264]) +2023-08-27 20:16:17,186 CRIT uncaptured python exception, closing channel (stdout)> (:[Errno 29] Invalid seek [/usr/lib/python3.11/site-packages/supervisor/supervisord.py|runforever|218] [/usr/lib/python3.11/site-packages/supervisor/dispatchers.py|handle_read_event|276] [/usr/lib/python3.11/site-packages/supervisor/dispatchers.py|record_output|210] [/usr/lib/python3.11/site-packages/supervisor/dispatchers.py|_log|179] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|info|327] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|log|345] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|emit|227] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|doRollover|264]) +2023-08-27 20:20:19,453 INFO Set uid to user 0 succeeded +2023-08-27 20:20:19,455 INFO supervisord started with pid 8 +2023-08-27 20:20:20,459 INFO spawned: 'nginx-unit' with pid 9 +2023-08-27 20:20:20,462 INFO spawned: 'php-logs' with pid 10 +2023-08-27 20:20:21,877 INFO success: nginx-unit entered RUNNING state, process has stayed up for > than 1 seconds (startsecs) +2023-08-27 20:20:21,878 INFO success: php-logs entered RUNNING state, process has stayed up for > than 1 seconds (startsecs) diff --git a/supervisord.pid b/supervisord.pid new file mode 100644 index 00000000..45a4fb75 --- /dev/null +++ b/supervisord.pid @@ -0,0 +1 @@ +8 From 0a65d0eec4940490a92343ee132f9efbefa30ca0 Mon Sep 17 00:00:00 2001 From: Syndesi Date: Thu, 31 Aug 2023 14:04:32 +0200 Subject: [PATCH 8/9] Improve logging. --- .gitignore | 3 + config/packages/monolog.yaml | 3 +- config/services.yaml | 3 + src/Command/BackupListCommand.php | 2 + .../Element/DeleteElementController.php | 2 +- .../Element/GetChildrenController.php | 2 +- .../Element/GetElementController.php | 2 +- src/Controller/Element/GetIndexController.php | 2 +- .../Element/GetParentsController.php | 2 +- .../Element/GetRelatedController.php | 2 +- .../Element/PatchElementController.php | 2 +- .../Element/PostElementController.php | 4 +- .../Element/PostIndexController.php | 6 +- .../Element/PutElementController.php | 2 +- .../File/DeleteElementFileController.php | 2 +- .../File/GetElementFileController.php | 2 +- .../File/PatchElementFileController.php | 2 +- .../File/PostElementFileController.php | 2 +- .../File/PutElementFileController.php | 2 +- .../Search/PostSearchController.php | 2 +- .../GetInstanceConfigurationController.php | 2 +- .../User/PostRegisterController.php | 4 +- src/Controller/User/PostTokenController.php | 2 +- .../WebDAV/CopyElementController.php | 2 +- .../WebDAV/LockElementController.php | 2 +- .../WebDAV/MkcolElementController.php | 2 +- .../WebDAV/MoveElementController.php | 2 +- .../WebDAV/PropfindElementController.php | 2 +- .../WebDAV/ProppatchElementController.php | 2 +- .../WebDAV/UnlockElementController.php | 2 +- .../EventListener/ExceptionEventListener.php | 8 +- .../EventListener/LogRequestListener.php | 66 ++++++++ .../EventListener/RouterListener.php.dis | 152 ++++++++++++++++++ src/EventSystem/Request/config.yaml | 16 ++ supervisord.log | 98 ----------- supervisord.pid | 1 - 36 files changed, 281 insertions(+), 131 deletions(-) create mode 100644 src/EventSystem/Request/EventListener/LogRequestListener.php create mode 100644 src/EventSystem/Request/EventListener/RouterListener.php.dis delete mode 100644 supervisord.log delete mode 100644 supervisord.pid diff --git a/.gitignore b/.gitignore index 246f3ffa..94b423ae 100755 --- a/.gitignore +++ b/.gitignore @@ -23,3 +23,6 @@ .phpunit.result.cache /phpunit.xml ###< symfony/phpunit-bridge ### + +supervisord.log +supervisord.pid diff --git a/config/packages/monolog.yaml b/config/packages/monolog.yaml index 8252fe9d..d763877f 100755 --- a/config/packages/monolog.yaml +++ b/config/packages/monolog.yaml @@ -9,7 +9,8 @@ when@dev: type: stream path: "%kernel.logs_dir%/log.log" level: debug - channels: ["!event"] + channels: ["!event", "!request"] + formatter: monolog_json_formatter console: type: console process_psr_3_messages: false diff --git a/config/services.yaml b/config/services.yaml index 5d1ccb73..3c75052a 100755 --- a/config/services.yaml +++ b/config/services.yaml @@ -31,6 +31,9 @@ services: # library services + monolog_json_formatter: + class: Monolog\Formatter\JsonFormatter + Syndesi\CypherEntityManager\EventListener\OpenCypher\NodeCreateToStatementEventListener: tags: - name: kernel.event_listener diff --git a/src/Command/BackupListCommand.php b/src/Command/BackupListCommand.php index 61303e34..a99fa845 100755 --- a/src/Command/BackupListCommand.php +++ b/src/Command/BackupListCommand.php @@ -32,6 +32,8 @@ protected function execute(InputInterface $input, OutputInterface $output): int $this->io->title('Backup List'); + $this->logger->notice('Notice :D 789'); + $rows = []; $header = [ 'Name', diff --git a/src/Controller/Element/DeleteElementController.php b/src/Controller/Element/DeleteElementController.php index 4663b46c..e5e30ff6 100644 --- a/src/Controller/Element/DeleteElementController.php +++ b/src/Controller/Element/DeleteElementController.php @@ -28,7 +28,7 @@ public function __construct( #[Route( '/{uuid}', - name: 'deleteElement', + name: 'delete-element', requirements: [ 'uuid' => Regex::UUID_V4_CONTROLLER, ], diff --git a/src/Controller/Element/GetChildrenController.php b/src/Controller/Element/GetChildrenController.php index 064c22e9..8c236f72 100644 --- a/src/Controller/Element/GetChildrenController.php +++ b/src/Controller/Element/GetChildrenController.php @@ -31,7 +31,7 @@ public function __construct( #[Route( '/{uuid}/children', - name: 'getChildren', + name: 'get-children', requirements: [ 'uuid' => Regex::UUID_V4_CONTROLLER, ], diff --git a/src/Controller/Element/GetElementController.php b/src/Controller/Element/GetElementController.php index 8770aea6..02026f55 100644 --- a/src/Controller/Element/GetElementController.php +++ b/src/Controller/Element/GetElementController.php @@ -27,7 +27,7 @@ public function __construct( #[Route( '/{uuid}', - name: 'getElement', + name: 'get-element', requirements: [ 'uuid' => Regex::UUID_V4_CONTROLLER, ], diff --git a/src/Controller/Element/GetIndexController.php b/src/Controller/Element/GetIndexController.php index a6649cdf..3c25e812 100644 --- a/src/Controller/Element/GetIndexController.php +++ b/src/Controller/Element/GetIndexController.php @@ -24,7 +24,7 @@ public function __construct( #[Route( '/', - name: 'getIndex', + name: 'get-index', methods: ['GET'] )] public function getIndex(): Response diff --git a/src/Controller/Element/GetParentsController.php b/src/Controller/Element/GetParentsController.php index 796135e0..040f0a87 100644 --- a/src/Controller/Element/GetParentsController.php +++ b/src/Controller/Element/GetParentsController.php @@ -31,7 +31,7 @@ public function __construct( #[Route( '/{uuid}/parents', - name: 'getParents', + name: 'get-parents', requirements: [ 'uuid' => Regex::UUID_V4_CONTROLLER, ], diff --git a/src/Controller/Element/GetRelatedController.php b/src/Controller/Element/GetRelatedController.php index e2350378..b56bebcc 100644 --- a/src/Controller/Element/GetRelatedController.php +++ b/src/Controller/Element/GetRelatedController.php @@ -31,7 +31,7 @@ public function __construct( #[Route( '/{uuid}/related', - name: 'getRelated', + name: 'get-related', requirements: [ 'uuid' => Regex::UUID_V4_CONTROLLER, ], diff --git a/src/Controller/Element/PatchElementController.php b/src/Controller/Element/PatchElementController.php index d8608fd9..e3268daf 100644 --- a/src/Controller/Element/PatchElementController.php +++ b/src/Controller/Element/PatchElementController.php @@ -29,7 +29,7 @@ public function __construct( #[Route( '/{uuid}', - name: 'patchElement', + name: 'patch-element', requirements: [ 'uuid' => Regex::UUID_V4_CONTROLLER, ], diff --git a/src/Controller/Element/PostElementController.php b/src/Controller/Element/PostElementController.php index c48a1c76..f4a556bd 100644 --- a/src/Controller/Element/PostElementController.php +++ b/src/Controller/Element/PostElementController.php @@ -38,7 +38,7 @@ public function __construct( #[Route( '/{uuid}', - name: 'postElement', + name: 'post-element', requirements: [ 'uuid' => Regex::UUID_V4_CONTROLLER, ], @@ -109,7 +109,7 @@ public function postElement(string $uuid, Request $request): Response return new CreatedResponse( $this->router->generate( - 'getElement', + 'get-element', [ 'uuid' => $newNodeUuid, ] diff --git a/src/Controller/Element/PostIndexController.php b/src/Controller/Element/PostIndexController.php index dcb6ac31..b701d4fa 100644 --- a/src/Controller/Element/PostIndexController.php +++ b/src/Controller/Element/PostIndexController.php @@ -38,7 +38,7 @@ public function __construct( #[Route( '/', - name: 'postIndex', + name: 'post-index', methods: ['POST'] )] public function postIndex(Request $request): Response @@ -144,7 +144,7 @@ private function createNode(string $type, UuidInterface $nodeId, array $data): R return new CreatedResponse( $this->router->generate( - 'getElement', + 'get-element', [ 'uuid' => $nodeId, ] @@ -182,7 +182,7 @@ private function createRelation(string $type, UuidInterface $relationId, UuidInt return new CreatedResponse( $this->router->generate( - 'getElement', + 'get-element', [ 'uuid' => $relationId, ] diff --git a/src/Controller/Element/PutElementController.php b/src/Controller/Element/PutElementController.php index 855cbb20..60d72112 100644 --- a/src/Controller/Element/PutElementController.php +++ b/src/Controller/Element/PutElementController.php @@ -29,7 +29,7 @@ public function __construct( #[Route( '/{uuid}', - name: 'putElement', + name: 'put-element', requirements: [ 'uuid' => Regex::UUID_V4_CONTROLLER, ], diff --git a/src/Controller/File/DeleteElementFileController.php b/src/Controller/File/DeleteElementFileController.php index 6b2079e1..96a91190 100644 --- a/src/Controller/File/DeleteElementFileController.php +++ b/src/Controller/File/DeleteElementFileController.php @@ -18,7 +18,7 @@ public function __construct( #[Route( '/{uuid}/file', - name: 'deleteElementFile', + name: 'delete-element-file', requirements: [ 'uuid' => Regex::UUID_V4_CONTROLLER, ], diff --git a/src/Controller/File/GetElementFileController.php b/src/Controller/File/GetElementFileController.php index 047a3172..d97850d4 100644 --- a/src/Controller/File/GetElementFileController.php +++ b/src/Controller/File/GetElementFileController.php @@ -18,7 +18,7 @@ public function __construct( #[Route( '/{uuid}/file', - name: 'getElementFile', + name: 'get-element-file', requirements: [ 'uuid' => Regex::UUID_V4_CONTROLLER, ], diff --git a/src/Controller/File/PatchElementFileController.php b/src/Controller/File/PatchElementFileController.php index bf486c11..da8a02f4 100644 --- a/src/Controller/File/PatchElementFileController.php +++ b/src/Controller/File/PatchElementFileController.php @@ -18,7 +18,7 @@ public function __construct( #[Route( '/{uuid}/file', - name: 'patchElementFile', + name: 'patch-element-file', requirements: [ 'uuid' => Regex::UUID_V4_CONTROLLER, ], diff --git a/src/Controller/File/PostElementFileController.php b/src/Controller/File/PostElementFileController.php index ffa2f674..7be4d35f 100644 --- a/src/Controller/File/PostElementFileController.php +++ b/src/Controller/File/PostElementFileController.php @@ -18,7 +18,7 @@ public function __construct( #[Route( '/{uuid}/file', - name: 'postElementFile', + name: 'post-element-file', requirements: [ 'uuid' => Regex::UUID_V4_CONTROLLER, ], diff --git a/src/Controller/File/PutElementFileController.php b/src/Controller/File/PutElementFileController.php index 544eaf6e..15ea2213 100644 --- a/src/Controller/File/PutElementFileController.php +++ b/src/Controller/File/PutElementFileController.php @@ -18,7 +18,7 @@ public function __construct( #[Route( '/{uuid}/file', - name: 'putElementFile', + name: 'put-element-file', requirements: [ 'uuid' => Regex::UUID_V4_CONTROLLER, ], diff --git a/src/Controller/Search/PostSearchController.php b/src/Controller/Search/PostSearchController.php index 2a291935..3818d7cc 100644 --- a/src/Controller/Search/PostSearchController.php +++ b/src/Controller/Search/PostSearchController.php @@ -33,7 +33,7 @@ public function __construct( #[Route( '/search', - name: 'postSearch', + name: 'post-search', methods: ['POST'] )] public function postSearch(Request $request): Response diff --git a/src/Controller/System/GetInstanceConfigurationController.php b/src/Controller/System/GetInstanceConfigurationController.php index 878bf370..49dad701 100644 --- a/src/Controller/System/GetInstanceConfigurationController.php +++ b/src/Controller/System/GetInstanceConfigurationController.php @@ -21,7 +21,7 @@ public function __construct( #[Route( '/instance-configuration', - name: 'getInstanceConfiguration', + name: 'get-instance-configuration', methods: ['GET'] )] public function getInstanceConfiguration(): Response diff --git a/src/Controller/User/PostRegisterController.php b/src/Controller/User/PostRegisterController.php index fb668301..a4d138fc 100644 --- a/src/Controller/User/PostRegisterController.php +++ b/src/Controller/User/PostRegisterController.php @@ -35,7 +35,7 @@ public function __construct( #[Route( '/register', - name: 'postRegister', + name: 'post-register', methods: ['POST'] )] public function postRegister(Request $request): Response @@ -92,7 +92,7 @@ public function postRegister(Request $request): Response return new CreatedResponse( $this->router->generate( - 'getElement', + 'get-element', [ 'uuid' => $userId, ] diff --git a/src/Controller/User/PostTokenController.php b/src/Controller/User/PostTokenController.php index c5ffebfa..0ca9ba8e 100644 --- a/src/Controller/User/PostTokenController.php +++ b/src/Controller/User/PostTokenController.php @@ -22,7 +22,7 @@ public function __construct( #[Route( '/token', - name: 'postToken', + name: 'post-token', methods: ['POST'] )] public function postToken(Request $request): Response diff --git a/src/Controller/WebDAV/CopyElementController.php b/src/Controller/WebDAV/CopyElementController.php index abdd962b..80ff07c7 100644 --- a/src/Controller/WebDAV/CopyElementController.php +++ b/src/Controller/WebDAV/CopyElementController.php @@ -18,7 +18,7 @@ public function __construct( #[Route( '/{uuid}', - name: 'copyElement', + name: 'copy-element', requirements: [ 'uuid' => Regex::UUID_V4_CONTROLLER, ], diff --git a/src/Controller/WebDAV/LockElementController.php b/src/Controller/WebDAV/LockElementController.php index acb3622d..bd76dbb4 100644 --- a/src/Controller/WebDAV/LockElementController.php +++ b/src/Controller/WebDAV/LockElementController.php @@ -18,7 +18,7 @@ public function __construct( #[Route( '/{uuid}', - name: 'lockElement', + name: 'lock-element', requirements: [ 'uuid' => Regex::UUID_V4_CONTROLLER, ], diff --git a/src/Controller/WebDAV/MkcolElementController.php b/src/Controller/WebDAV/MkcolElementController.php index 5ad6a682..d80beb1e 100644 --- a/src/Controller/WebDAV/MkcolElementController.php +++ b/src/Controller/WebDAV/MkcolElementController.php @@ -18,7 +18,7 @@ public function __construct( #[Route( '/{uuid}', - name: 'mkcolElement', + name: 'mkcol-element', requirements: [ 'uuid' => Regex::UUID_V4_CONTROLLER, ], diff --git a/src/Controller/WebDAV/MoveElementController.php b/src/Controller/WebDAV/MoveElementController.php index 613db6cc..8760c6e4 100644 --- a/src/Controller/WebDAV/MoveElementController.php +++ b/src/Controller/WebDAV/MoveElementController.php @@ -18,7 +18,7 @@ public function __construct( #[Route( '/{uuid}', - name: 'moveElement', + name: 'move-element', requirements: [ 'uuid' => Regex::UUID_V4_CONTROLLER, ], diff --git a/src/Controller/WebDAV/PropfindElementController.php b/src/Controller/WebDAV/PropfindElementController.php index fd573b00..0b95ce49 100644 --- a/src/Controller/WebDAV/PropfindElementController.php +++ b/src/Controller/WebDAV/PropfindElementController.php @@ -18,7 +18,7 @@ public function __construct( #[Route( '/{uuid}', - name: 'propfindElement', + name: 'propfind-element', requirements: [ 'uuid' => Regex::UUID_V4_CONTROLLER, ], diff --git a/src/Controller/WebDAV/ProppatchElementController.php b/src/Controller/WebDAV/ProppatchElementController.php index 57f01687..e8c6b1a7 100644 --- a/src/Controller/WebDAV/ProppatchElementController.php +++ b/src/Controller/WebDAV/ProppatchElementController.php @@ -18,7 +18,7 @@ public function __construct( #[Route( '/{uuid}', - name: 'proppatchElement', + name: 'proppatch-element', requirements: [ 'uuid' => Regex::UUID_V4_CONTROLLER, ], diff --git a/src/Controller/WebDAV/UnlockElementController.php b/src/Controller/WebDAV/UnlockElementController.php index 4ed19552..3157203f 100644 --- a/src/Controller/WebDAV/UnlockElementController.php +++ b/src/Controller/WebDAV/UnlockElementController.php @@ -18,7 +18,7 @@ public function __construct( #[Route( '/{uuid}', - name: 'unlockElement', + name: 'unlock-element', requirements: [ 'uuid' => Regex::UUID_V4_CONTROLLER, ], diff --git a/src/EventSystem/Exception/EventListener/ExceptionEventListener.php b/src/EventSystem/Exception/EventListener/ExceptionEventListener.php index 425af899..b4778dec 100644 --- a/src/EventSystem/Exception/EventListener/ExceptionEventListener.php +++ b/src/EventSystem/Exception/EventListener/ExceptionEventListener.php @@ -28,7 +28,7 @@ public function __construct( */ public function onKernelException(ExceptionEvent $event): void { - $this->logger->error($event->getThrowable()); + // $this->logger->error($event->getThrowable()); $originalException = $extendedException = $event->getThrowable(); if (!($originalException instanceof ProblemJsonException)) { $extendedException = $this->server500InternalServerErrorExceptionFactory->createFromTemplate('Other internal exception.'); @@ -80,6 +80,12 @@ public function onKernelException(ExceptionEvent $event): void 'trace' => $originalException->getTrace(), ]; } + $this->logger->error(sprintf( + '%s %s: %s', + $extendedException->getType(), + $extendedException->getTitle(), + $extendedException->getMessage() + )); $event->setResponse(new ProblemJsonResponse( $data, diff --git a/src/EventSystem/Request/EventListener/LogRequestListener.php b/src/EventSystem/Request/EventListener/LogRequestListener.php new file mode 100644 index 00000000..6969bc1b --- /dev/null +++ b/src/EventSystem/Request/EventListener/LogRequestListener.php @@ -0,0 +1,66 @@ +isMainRequest()) { + return; + } + $this->request = $event->getRequest(); + } + + public function onKernelResponse(ResponseEvent $event): void + { + $response = $event->getResponse(); + + if ($this->matcher instanceof RequestMatcherInterface) { + $parameters = $this->matcher->matchRequest($this->request); + } else { + $parameters = $this->matcher->match($this->request->getPathInfo()); + } + + $this->logger->info( + 'Handled request.', + [ + 'client' => [ + 'user' => $this->authProvider->isAnonymous() ? 'anonymous' : $this->authProvider->getUserUuid(), + 'token' => $this->authProvider->getTokenUuid(), + 'ip' => $this->request->getClientIp(), + ], + 'request' => [ + 'route' => $parameters['_route'] ?? 'n/a', + 'uri' => $this->request->getUri(), + 'method' => $this->request->getMethod(), + 'type' => $this->request->getContentTypeFormat(), + ], + 'response' => [ + 'status' => $response->getStatusCode(), + 'type' => $response->headers->get('content-type'), + ], + ] + ); + } +} diff --git a/src/EventSystem/Request/EventListener/RouterListener.php.dis b/src/EventSystem/Request/EventListener/RouterListener.php.dis new file mode 100644 index 00000000..bfe22c41 --- /dev/null +++ b/src/EventSystem/Request/EventListener/RouterListener.php.dis @@ -0,0 +1,152 @@ +matcher = $matcher; + $this->context = $context ?? $matcher->getContext(); + $this->requestStack = $requestStack; + $this->logger = $logger; + $this->projectDir = $projectDir; + $this->debug = $debug; + } + + private function setCurrentRequest(?Request $request): void + { + if (null !== $request) { + try { + $this->context->fromRequest($request); + } catch (\UnexpectedValueException $e) { + throw new BadRequestHttpException($e->getMessage(), $e, $e->getCode()); + } + } + } + + /** + * After a sub-request is done, we need to reset the routing context to the parent request so that the URL generator + * operates on the correct context again. + */ + public function onKernelFinishRequest(): void + { + $this->setCurrentRequest($this->requestStack->getParentRequest()); + } + + public function onKernelRequest(RequestEvent $event): void + { + $request = $event->getRequest(); + + $this->setCurrentRequest($request); + + if ($request->attributes->has('_controller')) { + // routing is already done + return; + } + + // add attributes based on the request (routing) + try { + // matching a request is more powerful than matching a URL path + context, so try that first + if ($this->matcher instanceof RequestMatcherInterface) { + $parameters = $this->matcher->matchRequest($request); + } else { + $parameters = $this->matcher->match($request->getPathInfo()); + } + + $this->logger?->info('Handled request', [ + 'route' => $parameters['_route'] ?? 'n/a', + 'request_uri' => $request->getUri(), + 'method' => $request->getMethod(), + 'ip' => $request->getClientIp(), + 'user' => '77e6df43-7465-4b23-b8b8-bc8c1f7e79c1', + 'token' => 'anonymous' + ]); + + $request->attributes->add($parameters); + unset($parameters['_route'], $parameters['_controller']); + $request->attributes->set('_route_params', $parameters); + } catch (ResourceNotFoundException $e) { + $message = sprintf('No route found for "%s %s"', $request->getMethod(), $request->getUriForPath($request->getPathInfo())); + + if ($referer = $request->headers->get('referer')) { + $message .= sprintf(' (from "%s")', $referer); + } + + throw new NotFoundHttpException($message, $e); + } catch (MethodNotAllowedException $e) { + $message = sprintf('No route found for "%s %s": Method Not Allowed (Allow: %s)', $request->getMethod(), $request->getUriForPath($request->getPathInfo()), implode(', ', $e->getAllowedMethods())); + + throw new MethodNotAllowedHttpException($e->getAllowedMethods(), $message, $e); + } + } + + public function onKernelException(ExceptionEvent $event): void + { + if (!$this->debug || !($e = $event->getThrowable()) instanceof NotFoundHttpException) { + return; + } + + if ($e->getPrevious() instanceof NoConfigurationException) { + $event->setResponse($this->createWelcomeResponse()); + } + } + + public static function getSubscribedEvents(): array + { + return [ + KernelEvents::REQUEST => [['onKernelRequest', 32]], + KernelEvents::FINISH_REQUEST => [['onKernelFinishRequest', 0]], + KernelEvents::EXCEPTION => ['onKernelException', -64], + ]; + } + + private function createWelcomeResponse(): Response + { + $version = Kernel::VERSION; + $projectDir = realpath((string) $this->projectDir).\DIRECTORY_SEPARATOR; + $docVersion = substr(Kernel::VERSION, 0, 3); + + ob_start(); + include \dirname(__DIR__).'/Resources/welcome.html.php'; + + return new Response(ob_get_clean(), Response::HTTP_NOT_FOUND); + } +} diff --git a/src/EventSystem/Request/config.yaml b/src/EventSystem/Request/config.yaml index 108dce15..aa111396 100644 --- a/src/EventSystem/Request/config.yaml +++ b/src/EventSystem/Request/config.yaml @@ -9,3 +9,19 @@ services: - name: kernel.event_listener event: 'kernel.request' method: 'onKernelRequest' + +# App\EventSystem\Request\EventListener\RouterListener: +# arguments: +# $matcher: '@router.default' + + + App\EventSystem\Request\EventListener\LogRequestListener: + arguments: + $matcher: '@router.default' + tags: + - name: kernel.event_listener + event: 'kernel.request' + method: 'onKernelRequest' + - name: kernel.event_listener + event: 'kernel.response' + method: 'onKernelResponse' diff --git a/supervisord.log b/supervisord.log deleted file mode 100644 index ce2ba517..00000000 --- a/supervisord.log +++ /dev/null @@ -1,98 +0,0 @@ -2023-08-27 20:09:44,320 CRIT Supervisor is running as root. Privileges were not dropped because no user is specified in the config file. If you intend to run as root, you can set user=root in the config file to avoid this message. -2023-08-27 20:09:44,322 INFO supervisord started with pid 8 -2023-08-27 20:09:45,324 INFO spawned: 'nginx-unit' with pid 9 -2023-08-27 20:09:45,326 INFO spawned: 'php-logs' with pid 10 -2023-08-27 20:09:45,338 CRIT uncaptured python exception, closing channel (stdout)> (:[Errno 29] Invalid seek [/usr/lib/python3.11/site-packages/supervisor/supervisord.py|runforever|218] [/usr/lib/python3.11/site-packages/supervisor/dispatchers.py|handle_read_event|276] [/usr/lib/python3.11/site-packages/supervisor/dispatchers.py|record_output|210] [/usr/lib/python3.11/site-packages/supervisor/dispatchers.py|_log|179] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|info|327] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|log|345] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|emit|227] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|doRollover|264]) -2023-08-27 20:09:45,352 CRIT uncaptured python exception, closing channel (stdout)> (:[Errno 29] Invalid seek [/usr/lib/python3.11/site-packages/supervisor/supervisord.py|runforever|218] [/usr/lib/python3.11/site-packages/supervisor/dispatchers.py|handle_read_event|276] [/usr/lib/python3.11/site-packages/supervisor/dispatchers.py|record_output|210] [/usr/lib/python3.11/site-packages/supervisor/dispatchers.py|_log|179] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|info|327] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|log|345] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|emit|227] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|doRollover|264]) -2023-08-27 20:09:45,358 CRIT uncaptured python exception, closing channel (stdout)> (:[Errno 29] Invalid seek [/usr/lib/python3.11/site-packages/supervisor/supervisord.py|runforever|218] [/usr/lib/python3.11/site-packages/supervisor/dispatchers.py|handle_read_event|276] [/usr/lib/python3.11/site-packages/supervisor/dispatchers.py|record_output|210] [/usr/lib/python3.11/site-packages/supervisor/dispatchers.py|_log|179] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|info|327] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|log|345] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|emit|227] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|doRollover|264]) -2023-08-27 20:09:45,375 CRIT uncaptured python exception, closing channel (stdout)> (:[Errno 29] Invalid seek [/usr/lib/python3.11/site-packages/supervisor/supervisord.py|runforever|218] [/usr/lib/python3.11/site-packages/supervisor/dispatchers.py|handle_read_event|276] [/usr/lib/python3.11/site-packages/supervisor/dispatchers.py|record_output|210] [/usr/lib/python3.11/site-packages/supervisor/dispatchers.py|_log|179] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|info|327] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|log|345] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|emit|227] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|doRollover|264]) -2023-08-27 20:09:45,375 CRIT uncaptured python exception, closing channel (stdout)> (:[Errno 29] Invalid seek [/usr/lib/python3.11/site-packages/supervisor/supervisord.py|runforever|218] [/usr/lib/python3.11/site-packages/supervisor/dispatchers.py|handle_read_event|276] [/usr/lib/python3.11/site-packages/supervisor/dispatchers.py|record_output|210] [/usr/lib/python3.11/site-packages/supervisor/dispatchers.py|_log|179] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|info|327] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|log|345] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|emit|227] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|doRollover|264]) -2023-08-27 20:09:45,378 CRIT uncaptured python exception, closing channel (stdout)> (:[Errno 29] Invalid seek [/usr/lib/python3.11/site-packages/supervisor/supervisord.py|runforever|218] [/usr/lib/python3.11/site-packages/supervisor/dispatchers.py|handle_read_event|276] [/usr/lib/python3.11/site-packages/supervisor/dispatchers.py|record_output|210] [/usr/lib/python3.11/site-packages/supervisor/dispatchers.py|_log|179] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|info|327] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|log|345] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|emit|227] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|doRollover|264]) -2023-08-27 20:09:45,379 CRIT uncaptured python exception, closing channel (stdout)> (:[Errno 29] Invalid seek [/usr/lib/python3.11/site-packages/supervisor/supervisord.py|runforever|218] [/usr/lib/python3.11/site-packages/supervisor/dispatchers.py|handle_read_event|276] [/usr/lib/python3.11/site-packages/supervisor/dispatchers.py|record_output|210] [/usr/lib/python3.11/site-packages/supervisor/dispatchers.py|_log|179] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|info|327] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|log|345] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|emit|227] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|doRollover|264]) -2023-08-27 20:09:45,381 CRIT uncaptured python exception, closing channel (stdout)> (:[Errno 29] Invalid seek [/usr/lib/python3.11/site-packages/supervisor/supervisord.py|runforever|218] [/usr/lib/python3.11/site-packages/supervisor/dispatchers.py|handle_read_event|276] [/usr/lib/python3.11/site-packages/supervisor/dispatchers.py|record_output|210] [/usr/lib/python3.11/site-packages/supervisor/dispatchers.py|_log|179] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|info|327] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|log|345] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|emit|227] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|doRollover|264]) -2023-08-27 20:09:45,386 CRIT uncaptured python exception, closing channel (stdout)> (:[Errno 29] Invalid seek [/usr/lib/python3.11/site-packages/supervisor/supervisord.py|runforever|218] [/usr/lib/python3.11/site-packages/supervisor/dispatchers.py|handle_read_event|276] [/usr/lib/python3.11/site-packages/supervisor/dispatchers.py|record_output|210] [/usr/lib/python3.11/site-packages/supervisor/dispatchers.py|_log|179] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|info|327] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|log|345] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|emit|227] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|doRollover|264]) -2023-08-27 20:09:45,389 CRIT uncaptured python exception, closing channel (stdout)> (:[Errno 29] Invalid seek [/usr/lib/python3.11/site-packages/supervisor/supervisord.py|runforever|218] [/usr/lib/python3.11/site-packages/supervisor/dispatchers.py|handle_read_event|276] [/usr/lib/python3.11/site-packages/supervisor/dispatchers.py|record_output|210] [/usr/lib/python3.11/site-packages/supervisor/dispatchers.py|_log|179] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|info|327] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|log|345] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|emit|227] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|doRollover|264]) -2023-08-27 20:09:45,389 CRIT uncaptured python exception, closing channel (stdout)> (:[Errno 29] Invalid seek [/usr/lib/python3.11/site-packages/supervisor/supervisord.py|runforever|218] [/usr/lib/python3.11/site-packages/supervisor/dispatchers.py|handle_read_event|276] [/usr/lib/python3.11/site-packages/supervisor/dispatchers.py|record_output|210] [/usr/lib/python3.11/site-packages/supervisor/dispatchers.py|_log|179] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|info|327] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|log|345] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|emit|227] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|doRollover|264]) -2023-08-27 20:09:45,440 CRIT uncaptured python exception, closing channel (stdout)> (:[Errno 29] Invalid seek [/usr/lib/python3.11/site-packages/supervisor/supervisord.py|runforever|218] [/usr/lib/python3.11/site-packages/supervisor/dispatchers.py|handle_read_event|276] [/usr/lib/python3.11/site-packages/supervisor/dispatchers.py|record_output|210] [/usr/lib/python3.11/site-packages/supervisor/dispatchers.py|_log|179] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|info|327] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|log|345] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|emit|227] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|doRollover|264]) -2023-08-27 20:09:45,445 CRIT uncaptured python exception, closing channel (stdout)> (:[Errno 29] Invalid seek [/usr/lib/python3.11/site-packages/supervisor/supervisord.py|runforever|218] [/usr/lib/python3.11/site-packages/supervisor/dispatchers.py|handle_read_event|276] [/usr/lib/python3.11/site-packages/supervisor/dispatchers.py|record_output|210] [/usr/lib/python3.11/site-packages/supervisor/dispatchers.py|_log|179] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|info|327] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|log|345] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|emit|227] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|doRollover|264]) -2023-08-27 20:09:45,455 CRIT uncaptured python exception, closing channel (stdout)> (:[Errno 29] Invalid seek [/usr/lib/python3.11/site-packages/supervisor/supervisord.py|runforever|218] [/usr/lib/python3.11/site-packages/supervisor/dispatchers.py|handle_read_event|276] [/usr/lib/python3.11/site-packages/supervisor/dispatchers.py|record_output|210] [/usr/lib/python3.11/site-packages/supervisor/dispatchers.py|_log|179] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|info|327] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|log|345] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|emit|227] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|doRollover|264]) -2023-08-27 20:09:45,462 CRIT uncaptured python exception, closing channel (stdout)> (:[Errno 29] Invalid seek [/usr/lib/python3.11/site-packages/supervisor/supervisord.py|runforever|218] [/usr/lib/python3.11/site-packages/supervisor/dispatchers.py|handle_read_event|276] [/usr/lib/python3.11/site-packages/supervisor/dispatchers.py|record_output|210] [/usr/lib/python3.11/site-packages/supervisor/dispatchers.py|_log|179] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|info|327] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|log|345] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|emit|227] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|doRollover|264]) -2023-08-27 20:09:45,467 CRIT uncaptured python exception, closing channel (stdout)> (:[Errno 29] Invalid seek [/usr/lib/python3.11/site-packages/supervisor/supervisord.py|runforever|218] [/usr/lib/python3.11/site-packages/supervisor/dispatchers.py|handle_read_event|276] [/usr/lib/python3.11/site-packages/supervisor/dispatchers.py|record_output|210] [/usr/lib/python3.11/site-packages/supervisor/dispatchers.py|_log|179] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|info|327] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|log|345] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|emit|227] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|doRollover|264]) -2023-08-27 20:09:45,467 CRIT uncaptured python exception, closing channel (stdout)> (:[Errno 29] Invalid seek [/usr/lib/python3.11/site-packages/supervisor/supervisord.py|runforever|218] [/usr/lib/python3.11/site-packages/supervisor/dispatchers.py|handle_read_event|276] [/usr/lib/python3.11/site-packages/supervisor/dispatchers.py|record_output|210] [/usr/lib/python3.11/site-packages/supervisor/dispatchers.py|_log|179] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|info|327] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|log|345] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|emit|227] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|doRollover|264]) -2023-08-27 20:09:45,468 CRIT uncaptured python exception, closing channel (stdout)> (:[Errno 29] Invalid seek [/usr/lib/python3.11/site-packages/supervisor/supervisord.py|runforever|218] [/usr/lib/python3.11/site-packages/supervisor/dispatchers.py|handle_read_event|276] [/usr/lib/python3.11/site-packages/supervisor/dispatchers.py|record_output|210] [/usr/lib/python3.11/site-packages/supervisor/dispatchers.py|_log|179] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|info|327] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|log|345] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|emit|227] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|doRollover|264]) -2023-08-27 20:09:45,469 CRIT uncaptured python exception, closing channel (stdout)> (:[Errno 29] Invalid seek [/usr/lib/python3.11/site-packages/supervisor/supervisord.py|runforever|218] [/usr/lib/python3.11/site-packages/supervisor/dispatchers.py|handle_read_event|276] [/usr/lib/python3.11/site-packages/supervisor/dispatchers.py|record_output|210] [/usr/lib/python3.11/site-packages/supervisor/dispatchers.py|_log|179] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|info|327] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|log|345] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|emit|227] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|doRollover|264]) -2023-08-27 20:09:45,471 CRIT uncaptured python exception, closing channel (stdout)> (:[Errno 29] Invalid seek [/usr/lib/python3.11/site-packages/supervisor/supervisord.py|runforever|218] [/usr/lib/python3.11/site-packages/supervisor/dispatchers.py|handle_read_event|276] [/usr/lib/python3.11/site-packages/supervisor/dispatchers.py|record_output|210] [/usr/lib/python3.11/site-packages/supervisor/dispatchers.py|_log|179] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|info|327] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|log|345] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|emit|227] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|doRollover|264]) -2023-08-27 20:09:46,475 CRIT uncaptured python exception, closing channel (stdout)> (:[Errno 29] Invalid seek [/usr/lib/python3.11/site-packages/supervisor/supervisord.py|runforever|218] [/usr/lib/python3.11/site-packages/supervisor/dispatchers.py|handle_read_event|276] [/usr/lib/python3.11/site-packages/supervisor/dispatchers.py|record_output|210] [/usr/lib/python3.11/site-packages/supervisor/dispatchers.py|_log|179] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|info|327] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|log|345] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|emit|227] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|doRollover|264]) -2023-08-27 20:09:46,476 INFO success: nginx-unit entered RUNNING state, process has stayed up for > than 1 seconds (startsecs) -2023-08-27 20:09:46,476 INFO success: php-logs entered RUNNING state, process has stayed up for > than 1 seconds (startsecs) -2023-08-27 20:09:46,484 CRIT uncaptured python exception, closing channel (stdout)> (:[Errno 29] Invalid seek [/usr/lib/python3.11/site-packages/supervisor/supervisord.py|runforever|218] [/usr/lib/python3.11/site-packages/supervisor/dispatchers.py|handle_read_event|276] [/usr/lib/python3.11/site-packages/supervisor/dispatchers.py|record_output|210] [/usr/lib/python3.11/site-packages/supervisor/dispatchers.py|_log|179] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|info|327] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|log|345] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|emit|227] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|doRollover|264]) -2023-08-27 20:09:46,485 CRIT uncaptured python exception, closing channel (stdout)> (:[Errno 29] Invalid seek [/usr/lib/python3.11/site-packages/supervisor/supervisord.py|runforever|218] [/usr/lib/python3.11/site-packages/supervisor/dispatchers.py|handle_read_event|276] [/usr/lib/python3.11/site-packages/supervisor/dispatchers.py|record_output|210] [/usr/lib/python3.11/site-packages/supervisor/dispatchers.py|_log|179] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|info|327] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|log|345] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|emit|227] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|doRollover|264]) -2023-08-27 20:09:46,491 CRIT uncaptured python exception, closing channel (stdout)> (:[Errno 29] Invalid seek [/usr/lib/python3.11/site-packages/supervisor/supervisord.py|runforever|218] [/usr/lib/python3.11/site-packages/supervisor/dispatchers.py|handle_read_event|276] [/usr/lib/python3.11/site-packages/supervisor/dispatchers.py|record_output|210] [/usr/lib/python3.11/site-packages/supervisor/dispatchers.py|_log|179] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|info|327] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|log|345] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|emit|227] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|doRollover|264]) -2023-08-27 20:09:46,491 CRIT uncaptured python exception, closing channel (stdout)> (:[Errno 29] Invalid seek [/usr/lib/python3.11/site-packages/supervisor/supervisord.py|runforever|218] [/usr/lib/python3.11/site-packages/supervisor/dispatchers.py|handle_read_event|276] [/usr/lib/python3.11/site-packages/supervisor/dispatchers.py|record_output|210] [/usr/lib/python3.11/site-packages/supervisor/dispatchers.py|_log|179] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|info|327] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|log|345] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|emit|227] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|doRollover|264]) -2023-08-27 20:09:46,492 CRIT uncaptured python exception, closing channel (stdout)> (:[Errno 29] Invalid seek [/usr/lib/python3.11/site-packages/supervisor/supervisord.py|runforever|218] [/usr/lib/python3.11/site-packages/supervisor/dispatchers.py|handle_read_event|276] [/usr/lib/python3.11/site-packages/supervisor/dispatchers.py|record_output|210] [/usr/lib/python3.11/site-packages/supervisor/dispatchers.py|_log|179] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|info|327] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|log|345] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|emit|227] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|doRollover|264]) -2023-08-27 20:09:46,492 CRIT uncaptured python exception, closing channel (stdout)> (:[Errno 29] Invalid seek [/usr/lib/python3.11/site-packages/supervisor/supervisord.py|runforever|218] [/usr/lib/python3.11/site-packages/supervisor/dispatchers.py|handle_read_event|276] [/usr/lib/python3.11/site-packages/supervisor/dispatchers.py|record_output|210] [/usr/lib/python3.11/site-packages/supervisor/dispatchers.py|_log|179] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|info|327] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|log|345] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|emit|227] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|doRollover|264]) -2023-08-27 20:09:46,510 CRIT uncaptured python exception, closing channel (stdout)> (:[Errno 29] Invalid seek [/usr/lib/python3.11/site-packages/supervisor/supervisord.py|runforever|218] [/usr/lib/python3.11/site-packages/supervisor/dispatchers.py|handle_read_event|276] [/usr/lib/python3.11/site-packages/supervisor/dispatchers.py|record_output|210] [/usr/lib/python3.11/site-packages/supervisor/dispatchers.py|_log|179] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|info|327] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|log|345] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|emit|227] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|doRollover|264]) -2023-08-27 20:09:46,579 CRIT uncaptured python exception, closing channel (stdout)> (:[Errno 29] Invalid seek [/usr/lib/python3.11/site-packages/supervisor/supervisord.py|runforever|218] [/usr/lib/python3.11/site-packages/supervisor/dispatchers.py|handle_read_event|276] [/usr/lib/python3.11/site-packages/supervisor/dispatchers.py|record_output|210] [/usr/lib/python3.11/site-packages/supervisor/dispatchers.py|_log|179] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|info|327] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|log|345] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|emit|227] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|doRollover|264]) -2023-08-27 20:09:46,581 CRIT uncaptured python exception, closing channel (stdout)> (:[Errno 29] Invalid seek [/usr/lib/python3.11/site-packages/supervisor/supervisord.py|runforever|218] [/usr/lib/python3.11/site-packages/supervisor/dispatchers.py|handle_read_event|276] [/usr/lib/python3.11/site-packages/supervisor/dispatchers.py|record_output|210] [/usr/lib/python3.11/site-packages/supervisor/dispatchers.py|_log|179] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|info|327] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|log|345] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|emit|227] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|doRollover|264]) -2023-08-27 20:10:48,797 CRIT Supervisor is running as root. Privileges were not dropped because no user is specified in the config file. If you intend to run as root, you can set user=root in the config file to avoid this message. -2023-08-27 20:10:48,801 INFO supervisord started with pid 10 -2023-08-27 20:10:49,803 INFO spawned: 'nginx-unit' with pid 11 -2023-08-27 20:10:49,806 INFO spawned: 'php-logs' with pid 12 -2023-08-27 20:10:49,810 CRIT uncaptured python exception, closing channel (stdout)> (:[Errno 29] Invalid seek [/usr/lib/python3.11/site-packages/supervisor/supervisord.py|runforever|218] [/usr/lib/python3.11/site-packages/supervisor/dispatchers.py|handle_read_event|276] [/usr/lib/python3.11/site-packages/supervisor/dispatchers.py|record_output|210] [/usr/lib/python3.11/site-packages/supervisor/dispatchers.py|_log|179] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|info|327] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|log|345] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|emit|227] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|doRollover|264]) -2023-08-27 20:10:49,822 CRIT uncaptured python exception, closing channel (stdout)> (:[Errno 29] Invalid seek [/usr/lib/python3.11/site-packages/supervisor/supervisord.py|runforever|218] [/usr/lib/python3.11/site-packages/supervisor/dispatchers.py|handle_read_event|276] [/usr/lib/python3.11/site-packages/supervisor/dispatchers.py|record_output|210] [/usr/lib/python3.11/site-packages/supervisor/dispatchers.py|_log|179] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|info|327] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|log|345] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|emit|227] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|doRollover|264]) -2023-08-27 20:10:49,823 CRIT uncaptured python exception, closing channel (stdout)> (:[Errno 29] Invalid seek [/usr/lib/python3.11/site-packages/supervisor/supervisord.py|runforever|218] [/usr/lib/python3.11/site-packages/supervisor/dispatchers.py|handle_read_event|276] [/usr/lib/python3.11/site-packages/supervisor/dispatchers.py|record_output|210] [/usr/lib/python3.11/site-packages/supervisor/dispatchers.py|_log|179] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|info|327] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|log|345] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|emit|227] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|doRollover|264]) -2023-08-27 20:10:49,841 CRIT uncaptured python exception, closing channel (stdout)> (:[Errno 29] Invalid seek [/usr/lib/python3.11/site-packages/supervisor/supervisord.py|runforever|218] [/usr/lib/python3.11/site-packages/supervisor/dispatchers.py|handle_read_event|276] [/usr/lib/python3.11/site-packages/supervisor/dispatchers.py|record_output|210] [/usr/lib/python3.11/site-packages/supervisor/dispatchers.py|_log|179] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|info|327] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|log|345] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|emit|227] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|doRollover|264]) -2023-08-27 20:10:49,842 CRIT uncaptured python exception, closing channel (stdout)> (:[Errno 29] Invalid seek [/usr/lib/python3.11/site-packages/supervisor/supervisord.py|runforever|218] [/usr/lib/python3.11/site-packages/supervisor/dispatchers.py|handle_read_event|276] [/usr/lib/python3.11/site-packages/supervisor/dispatchers.py|record_output|210] [/usr/lib/python3.11/site-packages/supervisor/dispatchers.py|_log|179] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|info|327] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|log|345] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|emit|227] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|doRollover|264]) -2023-08-27 20:10:49,843 CRIT uncaptured python exception, closing channel (stdout)> (:[Errno 29] Invalid seek [/usr/lib/python3.11/site-packages/supervisor/supervisord.py|runforever|218] [/usr/lib/python3.11/site-packages/supervisor/dispatchers.py|handle_read_event|276] [/usr/lib/python3.11/site-packages/supervisor/dispatchers.py|record_output|210] [/usr/lib/python3.11/site-packages/supervisor/dispatchers.py|_log|179] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|info|327] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|log|345] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|emit|227] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|doRollover|264]) -2023-08-27 20:10:49,844 CRIT uncaptured python exception, closing channel (stdout)> (:[Errno 29] Invalid seek [/usr/lib/python3.11/site-packages/supervisor/supervisord.py|runforever|218] [/usr/lib/python3.11/site-packages/supervisor/dispatchers.py|handle_read_event|276] [/usr/lib/python3.11/site-packages/supervisor/dispatchers.py|record_output|210] [/usr/lib/python3.11/site-packages/supervisor/dispatchers.py|_log|179] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|info|327] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|log|345] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|emit|227] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|doRollover|264]) -2023-08-27 20:10:49,845 CRIT uncaptured python exception, closing channel (stdout)> (:[Errno 29] Invalid seek [/usr/lib/python3.11/site-packages/supervisor/supervisord.py|runforever|218] [/usr/lib/python3.11/site-packages/supervisor/dispatchers.py|handle_read_event|276] [/usr/lib/python3.11/site-packages/supervisor/dispatchers.py|record_output|210] [/usr/lib/python3.11/site-packages/supervisor/dispatchers.py|_log|179] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|info|327] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|log|345] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|emit|227] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|doRollover|264]) -2023-08-27 20:10:49,906 CRIT uncaptured python exception, closing channel (stdout)> (:[Errno 29] Invalid seek [/usr/lib/python3.11/site-packages/supervisor/supervisord.py|runforever|218] [/usr/lib/python3.11/site-packages/supervisor/dispatchers.py|handle_read_event|276] [/usr/lib/python3.11/site-packages/supervisor/dispatchers.py|record_output|210] [/usr/lib/python3.11/site-packages/supervisor/dispatchers.py|_log|179] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|info|327] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|log|345] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|emit|227] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|doRollover|264]) -2023-08-27 20:10:49,909 CRIT uncaptured python exception, closing channel (stdout)> (:[Errno 29] Invalid seek [/usr/lib/python3.11/site-packages/supervisor/supervisord.py|runforever|218] [/usr/lib/python3.11/site-packages/supervisor/dispatchers.py|handle_read_event|276] [/usr/lib/python3.11/site-packages/supervisor/dispatchers.py|record_output|210] [/usr/lib/python3.11/site-packages/supervisor/dispatchers.py|_log|179] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|info|327] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|log|345] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|emit|227] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|doRollover|264]) -2023-08-27 20:10:50,910 INFO success: nginx-unit entered RUNNING state, process has stayed up for > than 1 seconds (startsecs) -2023-08-27 20:10:50,911 INFO success: php-logs entered RUNNING state, process has stayed up for > than 1 seconds (startsecs) -2023-08-27 20:11:45,817 CRIT uncaptured python exception, closing channel (stdout)> (:[Errno 29] Invalid seek [/usr/lib/python3.11/site-packages/supervisor/supervisord.py|runforever|218] [/usr/lib/python3.11/site-packages/supervisor/dispatchers.py|handle_read_event|276] [/usr/lib/python3.11/site-packages/supervisor/dispatchers.py|record_output|210] [/usr/lib/python3.11/site-packages/supervisor/dispatchers.py|_log|179] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|info|327] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|log|345] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|emit|227] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|doRollover|264]) -2023-08-27 20:12:12,820 CRIT uncaptured python exception, closing channel (stdout)> (:[Errno 29] Invalid seek [/usr/lib/python3.11/site-packages/supervisor/supervisord.py|runforever|218] [/usr/lib/python3.11/site-packages/supervisor/dispatchers.py|handle_read_event|276] [/usr/lib/python3.11/site-packages/supervisor/dispatchers.py|record_output|210] [/usr/lib/python3.11/site-packages/supervisor/dispatchers.py|_log|179] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|info|327] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|log|345] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|emit|227] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|doRollover|264]) -2023-08-27 20:16:14,778 INFO Set uid to user 0 succeeded -2023-08-27 20:16:14,780 INFO supervisord started with pid 9 -2023-08-27 20:16:15,782 INFO spawned: 'nginx-unit' with pid 10 -2023-08-27 20:16:15,784 INFO spawned: 'php-logs' with pid 11 -2023-08-27 20:16:15,789 CRIT uncaptured python exception, closing channel (stdout)> (:[Errno 29] Invalid seek [/usr/lib/python3.11/site-packages/supervisor/supervisord.py|runforever|218] [/usr/lib/python3.11/site-packages/supervisor/dispatchers.py|handle_read_event|276] [/usr/lib/python3.11/site-packages/supervisor/dispatchers.py|record_output|210] [/usr/lib/python3.11/site-packages/supervisor/dispatchers.py|_log|179] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|info|327] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|log|345] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|emit|227] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|doRollover|264]) -2023-08-27 20:16:15,829 CRIT uncaptured python exception, closing channel (stdout)> (:[Errno 29] Invalid seek [/usr/lib/python3.11/site-packages/supervisor/supervisord.py|runforever|218] [/usr/lib/python3.11/site-packages/supervisor/dispatchers.py|handle_read_event|276] [/usr/lib/python3.11/site-packages/supervisor/dispatchers.py|record_output|210] [/usr/lib/python3.11/site-packages/supervisor/dispatchers.py|_log|179] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|info|327] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|log|345] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|emit|227] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|doRollover|264]) -2023-08-27 20:16:15,830 CRIT uncaptured python exception, closing channel (stdout)> (:[Errno 29] Invalid seek [/usr/lib/python3.11/site-packages/supervisor/supervisord.py|runforever|218] [/usr/lib/python3.11/site-packages/supervisor/dispatchers.py|handle_read_event|276] [/usr/lib/python3.11/site-packages/supervisor/dispatchers.py|record_output|210] [/usr/lib/python3.11/site-packages/supervisor/dispatchers.py|_log|179] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|info|327] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|log|345] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|emit|227] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|doRollover|264]) -2023-08-27 20:16:15,862 CRIT uncaptured python exception, closing channel (stdout)> (:[Errno 29] Invalid seek [/usr/lib/python3.11/site-packages/supervisor/supervisord.py|runforever|218] [/usr/lib/python3.11/site-packages/supervisor/dispatchers.py|handle_read_event|276] [/usr/lib/python3.11/site-packages/supervisor/dispatchers.py|record_output|210] [/usr/lib/python3.11/site-packages/supervisor/dispatchers.py|_log|179] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|info|327] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|log|345] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|emit|227] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|doRollover|264]) -2023-08-27 20:16:15,867 CRIT uncaptured python exception, closing channel (stdout)> (:[Errno 29] Invalid seek [/usr/lib/python3.11/site-packages/supervisor/supervisord.py|runforever|218] [/usr/lib/python3.11/site-packages/supervisor/dispatchers.py|handle_read_event|276] [/usr/lib/python3.11/site-packages/supervisor/dispatchers.py|record_output|210] [/usr/lib/python3.11/site-packages/supervisor/dispatchers.py|_log|179] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|info|327] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|log|345] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|emit|227] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|doRollover|264]) -2023-08-27 20:16:15,867 CRIT uncaptured python exception, closing channel (stdout)> (:[Errno 29] Invalid seek [/usr/lib/python3.11/site-packages/supervisor/supervisord.py|runforever|218] [/usr/lib/python3.11/site-packages/supervisor/dispatchers.py|handle_read_event|276] [/usr/lib/python3.11/site-packages/supervisor/dispatchers.py|record_output|210] [/usr/lib/python3.11/site-packages/supervisor/dispatchers.py|_log|179] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|info|327] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|log|345] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|emit|227] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|doRollover|264]) -2023-08-27 20:16:15,868 CRIT uncaptured python exception, closing channel (stdout)> (:[Errno 29] Invalid seek [/usr/lib/python3.11/site-packages/supervisor/supervisord.py|runforever|218] [/usr/lib/python3.11/site-packages/supervisor/dispatchers.py|handle_read_event|276] [/usr/lib/python3.11/site-packages/supervisor/dispatchers.py|record_output|210] [/usr/lib/python3.11/site-packages/supervisor/dispatchers.py|_log|179] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|info|327] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|log|345] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|emit|227] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|doRollover|264]) -2023-08-27 20:16:15,868 CRIT uncaptured python exception, closing channel (stdout)> (:[Errno 29] Invalid seek [/usr/lib/python3.11/site-packages/supervisor/supervisord.py|runforever|218] [/usr/lib/python3.11/site-packages/supervisor/dispatchers.py|handle_read_event|276] [/usr/lib/python3.11/site-packages/supervisor/dispatchers.py|record_output|210] [/usr/lib/python3.11/site-packages/supervisor/dispatchers.py|_log|179] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|info|327] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|log|345] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|emit|227] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|doRollover|264]) -2023-08-27 20:16:15,871 CRIT uncaptured python exception, closing channel (stdout)> (:[Errno 29] Invalid seek [/usr/lib/python3.11/site-packages/supervisor/supervisord.py|runforever|218] [/usr/lib/python3.11/site-packages/supervisor/dispatchers.py|handle_read_event|276] [/usr/lib/python3.11/site-packages/supervisor/dispatchers.py|record_output|210] [/usr/lib/python3.11/site-packages/supervisor/dispatchers.py|_log|179] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|info|327] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|log|345] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|emit|227] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|doRollover|264]) -2023-08-27 20:16:15,872 CRIT uncaptured python exception, closing channel (stdout)> (:[Errno 29] Invalid seek [/usr/lib/python3.11/site-packages/supervisor/supervisord.py|runforever|218] [/usr/lib/python3.11/site-packages/supervisor/dispatchers.py|handle_read_event|276] [/usr/lib/python3.11/site-packages/supervisor/dispatchers.py|record_output|210] [/usr/lib/python3.11/site-packages/supervisor/dispatchers.py|_log|179] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|info|327] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|log|345] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|emit|227] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|doRollover|264]) -2023-08-27 20:16:15,893 CRIT uncaptured python exception, closing channel (stdout)> (:[Errno 29] Invalid seek [/usr/lib/python3.11/site-packages/supervisor/supervisord.py|runforever|218] [/usr/lib/python3.11/site-packages/supervisor/dispatchers.py|handle_read_event|276] [/usr/lib/python3.11/site-packages/supervisor/dispatchers.py|record_output|210] [/usr/lib/python3.11/site-packages/supervisor/dispatchers.py|_log|179] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|info|327] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|log|345] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|emit|227] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|doRollover|264]) -2023-08-27 20:16:15,900 CRIT uncaptured python exception, closing channel (stdout)> (:[Errno 29] Invalid seek [/usr/lib/python3.11/site-packages/supervisor/supervisord.py|runforever|218] [/usr/lib/python3.11/site-packages/supervisor/dispatchers.py|handle_read_event|276] [/usr/lib/python3.11/site-packages/supervisor/dispatchers.py|record_output|210] [/usr/lib/python3.11/site-packages/supervisor/dispatchers.py|_log|179] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|info|327] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|log|345] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|emit|227] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|doRollover|264]) -2023-08-27 20:16:15,970 CRIT uncaptured python exception, closing channel (stdout)> (:[Errno 29] Invalid seek [/usr/lib/python3.11/site-packages/supervisor/supervisord.py|runforever|218] [/usr/lib/python3.11/site-packages/supervisor/dispatchers.py|handle_read_event|276] [/usr/lib/python3.11/site-packages/supervisor/dispatchers.py|record_output|210] [/usr/lib/python3.11/site-packages/supervisor/dispatchers.py|_log|179] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|info|327] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|log|345] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|emit|227] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|doRollover|264]) -2023-08-27 20:16:15,973 CRIT uncaptured python exception, closing channel (stdout)> (:[Errno 29] Invalid seek [/usr/lib/python3.11/site-packages/supervisor/supervisord.py|runforever|218] [/usr/lib/python3.11/site-packages/supervisor/dispatchers.py|handle_read_event|276] [/usr/lib/python3.11/site-packages/supervisor/dispatchers.py|record_output|210] [/usr/lib/python3.11/site-packages/supervisor/dispatchers.py|_log|179] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|info|327] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|log|345] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|emit|227] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|doRollover|264]) -2023-08-27 20:16:16,005 CRIT uncaptured python exception, closing channel (stdout)> (:[Errno 29] Invalid seek [/usr/lib/python3.11/site-packages/supervisor/supervisord.py|runforever|218] [/usr/lib/python3.11/site-packages/supervisor/dispatchers.py|handle_read_event|276] [/usr/lib/python3.11/site-packages/supervisor/dispatchers.py|record_output|210] [/usr/lib/python3.11/site-packages/supervisor/dispatchers.py|_log|179] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|info|327] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|log|345] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|emit|227] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|doRollover|264]) -2023-08-27 20:16:16,006 CRIT uncaptured python exception, closing channel (stdout)> (:[Errno 29] Invalid seek [/usr/lib/python3.11/site-packages/supervisor/supervisord.py|runforever|218] [/usr/lib/python3.11/site-packages/supervisor/dispatchers.py|handle_read_event|276] [/usr/lib/python3.11/site-packages/supervisor/dispatchers.py|record_output|210] [/usr/lib/python3.11/site-packages/supervisor/dispatchers.py|_log|179] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|info|327] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|log|345] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|emit|227] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|doRollover|264]) -2023-08-27 20:16:16,016 CRIT uncaptured python exception, closing channel (stdout)> (:[Errno 29] Invalid seek [/usr/lib/python3.11/site-packages/supervisor/supervisord.py|runforever|218] [/usr/lib/python3.11/site-packages/supervisor/dispatchers.py|handle_read_event|276] [/usr/lib/python3.11/site-packages/supervisor/dispatchers.py|record_output|210] [/usr/lib/python3.11/site-packages/supervisor/dispatchers.py|_log|179] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|info|327] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|log|345] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|emit|227] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|doRollover|264]) -2023-08-27 20:16:16,018 CRIT uncaptured python exception, closing channel (stdout)> (:[Errno 29] Invalid seek [/usr/lib/python3.11/site-packages/supervisor/supervisord.py|runforever|218] [/usr/lib/python3.11/site-packages/supervisor/dispatchers.py|handle_read_event|276] [/usr/lib/python3.11/site-packages/supervisor/dispatchers.py|record_output|210] [/usr/lib/python3.11/site-packages/supervisor/dispatchers.py|_log|179] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|info|327] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|log|345] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|emit|227] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|doRollover|264]) -2023-08-27 20:16:16,018 CRIT uncaptured python exception, closing channel (stdout)> (:[Errno 29] Invalid seek [/usr/lib/python3.11/site-packages/supervisor/supervisord.py|runforever|218] [/usr/lib/python3.11/site-packages/supervisor/dispatchers.py|handle_read_event|276] [/usr/lib/python3.11/site-packages/supervisor/dispatchers.py|record_output|210] [/usr/lib/python3.11/site-packages/supervisor/dispatchers.py|_log|179] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|info|327] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|log|345] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|emit|227] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|doRollover|264]) -2023-08-27 20:16:16,018 CRIT uncaptured python exception, closing channel (stdout)> (:[Errno 29] Invalid seek [/usr/lib/python3.11/site-packages/supervisor/supervisord.py|runforever|218] [/usr/lib/python3.11/site-packages/supervisor/dispatchers.py|handle_read_event|276] [/usr/lib/python3.11/site-packages/supervisor/dispatchers.py|record_output|210] [/usr/lib/python3.11/site-packages/supervisor/dispatchers.py|_log|179] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|info|327] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|log|345] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|emit|227] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|doRollover|264]) -2023-08-27 20:16:16,021 CRIT uncaptured python exception, closing channel (stdout)> (:[Errno 29] Invalid seek [/usr/lib/python3.11/site-packages/supervisor/supervisord.py|runforever|218] [/usr/lib/python3.11/site-packages/supervisor/dispatchers.py|handle_read_event|276] [/usr/lib/python3.11/site-packages/supervisor/dispatchers.py|record_output|210] [/usr/lib/python3.11/site-packages/supervisor/dispatchers.py|_log|179] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|info|327] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|log|345] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|emit|227] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|doRollover|264]) -2023-08-27 20:16:16,023 CRIT uncaptured python exception, closing channel (stdout)> (:[Errno 29] Invalid seek [/usr/lib/python3.11/site-packages/supervisor/supervisord.py|runforever|218] [/usr/lib/python3.11/site-packages/supervisor/dispatchers.py|handle_read_event|276] [/usr/lib/python3.11/site-packages/supervisor/dispatchers.py|record_output|210] [/usr/lib/python3.11/site-packages/supervisor/dispatchers.py|_log|179] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|info|327] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|log|345] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|emit|227] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|doRollover|264]) -2023-08-27 20:16:17,020 CRIT uncaptured python exception, closing channel (stdout)> (:[Errno 29] Invalid seek [/usr/lib/python3.11/site-packages/supervisor/supervisord.py|runforever|218] [/usr/lib/python3.11/site-packages/supervisor/dispatchers.py|handle_read_event|276] [/usr/lib/python3.11/site-packages/supervisor/dispatchers.py|record_output|210] [/usr/lib/python3.11/site-packages/supervisor/dispatchers.py|_log|179] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|info|327] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|log|345] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|emit|227] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|doRollover|264]) -2023-08-27 20:16:17,020 INFO success: nginx-unit entered RUNNING state, process has stayed up for > than 1 seconds (startsecs) -2023-08-27 20:16:17,020 INFO success: php-logs entered RUNNING state, process has stayed up for > than 1 seconds (startsecs) -2023-08-27 20:16:17,030 CRIT uncaptured python exception, closing channel (stdout)> (:[Errno 29] Invalid seek [/usr/lib/python3.11/site-packages/supervisor/supervisord.py|runforever|218] [/usr/lib/python3.11/site-packages/supervisor/dispatchers.py|handle_read_event|276] [/usr/lib/python3.11/site-packages/supervisor/dispatchers.py|record_output|210] [/usr/lib/python3.11/site-packages/supervisor/dispatchers.py|_log|179] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|info|327] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|log|345] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|emit|227] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|doRollover|264]) -2023-08-27 20:16:17,031 CRIT uncaptured python exception, closing channel (stdout)> (:[Errno 29] Invalid seek [/usr/lib/python3.11/site-packages/supervisor/supervisord.py|runforever|218] [/usr/lib/python3.11/site-packages/supervisor/dispatchers.py|handle_read_event|276] [/usr/lib/python3.11/site-packages/supervisor/dispatchers.py|record_output|210] [/usr/lib/python3.11/site-packages/supervisor/dispatchers.py|_log|179] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|info|327] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|log|345] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|emit|227] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|doRollover|264]) -2023-08-27 20:16:17,036 CRIT uncaptured python exception, closing channel (stdout)> (:[Errno 29] Invalid seek [/usr/lib/python3.11/site-packages/supervisor/supervisord.py|runforever|218] [/usr/lib/python3.11/site-packages/supervisor/dispatchers.py|handle_read_event|276] [/usr/lib/python3.11/site-packages/supervisor/dispatchers.py|record_output|210] [/usr/lib/python3.11/site-packages/supervisor/dispatchers.py|_log|179] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|info|327] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|log|345] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|emit|227] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|doRollover|264]) -2023-08-27 20:16:17,037 CRIT uncaptured python exception, closing channel (stdout)> (:[Errno 29] Invalid seek [/usr/lib/python3.11/site-packages/supervisor/supervisord.py|runforever|218] [/usr/lib/python3.11/site-packages/supervisor/dispatchers.py|handle_read_event|276] [/usr/lib/python3.11/site-packages/supervisor/dispatchers.py|record_output|210] [/usr/lib/python3.11/site-packages/supervisor/dispatchers.py|_log|179] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|info|327] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|log|345] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|emit|227] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|doRollover|264]) -2023-08-27 20:16:17,039 CRIT uncaptured python exception, closing channel (stdout)> (:[Errno 29] Invalid seek [/usr/lib/python3.11/site-packages/supervisor/supervisord.py|runforever|218] [/usr/lib/python3.11/site-packages/supervisor/dispatchers.py|handle_read_event|276] [/usr/lib/python3.11/site-packages/supervisor/dispatchers.py|record_output|210] [/usr/lib/python3.11/site-packages/supervisor/dispatchers.py|_log|179] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|info|327] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|log|345] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|emit|227] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|doRollover|264]) -2023-08-27 20:16:17,039 CRIT uncaptured python exception, closing channel (stdout)> (:[Errno 29] Invalid seek [/usr/lib/python3.11/site-packages/supervisor/supervisord.py|runforever|218] [/usr/lib/python3.11/site-packages/supervisor/dispatchers.py|handle_read_event|276] [/usr/lib/python3.11/site-packages/supervisor/dispatchers.py|record_output|210] [/usr/lib/python3.11/site-packages/supervisor/dispatchers.py|_log|179] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|info|327] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|log|345] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|emit|227] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|doRollover|264]) -2023-08-27 20:16:17,041 CRIT uncaptured python exception, closing channel (stdout)> (:[Errno 29] Invalid seek [/usr/lib/python3.11/site-packages/supervisor/supervisord.py|runforever|218] [/usr/lib/python3.11/site-packages/supervisor/dispatchers.py|handle_read_event|276] [/usr/lib/python3.11/site-packages/supervisor/dispatchers.py|record_output|210] [/usr/lib/python3.11/site-packages/supervisor/dispatchers.py|_log|179] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|info|327] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|log|345] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|emit|227] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|doRollover|264]) -2023-08-27 20:16:17,177 CRIT uncaptured python exception, closing channel (stdout)> (:[Errno 29] Invalid seek [/usr/lib/python3.11/site-packages/supervisor/supervisord.py|runforever|218] [/usr/lib/python3.11/site-packages/supervisor/dispatchers.py|handle_read_event|276] [/usr/lib/python3.11/site-packages/supervisor/dispatchers.py|record_output|210] [/usr/lib/python3.11/site-packages/supervisor/dispatchers.py|_log|179] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|info|327] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|log|345] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|emit|227] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|doRollover|264]) -2023-08-27 20:16:17,186 CRIT uncaptured python exception, closing channel (stdout)> (:[Errno 29] Invalid seek [/usr/lib/python3.11/site-packages/supervisor/supervisord.py|runforever|218] [/usr/lib/python3.11/site-packages/supervisor/dispatchers.py|handle_read_event|276] [/usr/lib/python3.11/site-packages/supervisor/dispatchers.py|record_output|210] [/usr/lib/python3.11/site-packages/supervisor/dispatchers.py|_log|179] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|info|327] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|log|345] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|emit|227] [/usr/lib/python3.11/site-packages/supervisor/loggers.py|doRollover|264]) -2023-08-27 20:20:19,453 INFO Set uid to user 0 succeeded -2023-08-27 20:20:19,455 INFO supervisord started with pid 8 -2023-08-27 20:20:20,459 INFO spawned: 'nginx-unit' with pid 9 -2023-08-27 20:20:20,462 INFO spawned: 'php-logs' with pid 10 -2023-08-27 20:20:21,877 INFO success: nginx-unit entered RUNNING state, process has stayed up for > than 1 seconds (startsecs) -2023-08-27 20:20:21,878 INFO success: php-logs entered RUNNING state, process has stayed up for > than 1 seconds (startsecs) diff --git a/supervisord.pid b/supervisord.pid deleted file mode 100644 index 45a4fb75..00000000 --- a/supervisord.pid +++ /dev/null @@ -1 +0,0 @@ -8 From c8a4d072cb55f3710e7f1c879a298afc29f3b561 Mon Sep 17 00:00:00 2001 From: Syndesi Date: Thu, 31 Aug 2023 22:11:03 +0200 Subject: [PATCH 9/9] Fix dockerfile entrypoint. --- docker/nginx-unit/unit-entrypoint.sh | 2 +- docker/supervisord/docker-entrypoint.sh | 7 ++++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/docker/nginx-unit/unit-entrypoint.sh b/docker/nginx-unit/unit-entrypoint.sh index b8950488..e0afd7ea 100644 --- a/docker/nginx-unit/unit-entrypoint.sh +++ b/docker/nginx-unit/unit-entrypoint.sh @@ -89,4 +89,4 @@ if [ "$1" = "unitd" ] || [ "$1" = "unitd-debug" ]; then fi fi -exec "$@" \ No newline at end of file +exec "$@" diff --git a/docker/supervisord/docker-entrypoint.sh b/docker/supervisord/docker-entrypoint.sh index 4043eb63..1a19de53 100644 --- a/docker/supervisord/docker-entrypoint.sh +++ b/docker/supervisord/docker-entrypoint.sh @@ -4,4 +4,9 @@ set -e mkdir -p /var/www/html/var/logs touch /var/www/html/var/logs/log.log -supervisord --nodaemon --configuration /etc/supervisord.conf + +if [ -z "$@" ]; then + supervisord --nodaemon --configuration /etc/supervisord.conf +else + exec "$@" +fi