-
Notifications
You must be signed in to change notification settings - Fork 20
fix #92 live logs #93
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
oallain
wants to merge
8
commits into
3.x
Choose a base branch
from
fix/#92-live-logs
base: 3.x
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
b734e2b
better command interruption management
oallain eb08105
Better Exception throw
oallain 36c3366
Merge pull request #106 from synolia/feature/terminate-command
oallain 02edfa5
Add possibility of time date format 12/24 (#97)
vasilvestre c8877a4
feat(timezone): enable different timezone from that of php config
7024e75
use php attribute
oallain 2d07d8e
Merge pull request #98 from delyriand/feature/timezone-management
oallain 436b012
fix #92 live logs
oallain File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -68,6 +68,10 @@ | |||||
| cp -R vendor/synolia/sylius-scheduler-command-plugin/install/Application/config/packages/* config/packages/ | ||||||
| cp -R vendor/synolia/sylius-scheduler-command-plugin/install/Application/config/routes/* config/routes/ | ||||||
|
|
||||||
| 6. Installing assets (JS and CSS) fot the plugin | ||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
|
|
||||||
| bin/console assets:install | ||||||
|
|
||||||
| ## Usage | ||||||
|
|
||||||
| * Log into admin panel | ||||||
|
|
@@ -113,6 +117,12 @@ Execute scheduled commands. | |||||
|
|
||||||
| **Run a specific scheduled command :** php bin/console synolia:scheduler-run --id=5 | ||||||
|
|
||||||
| Is it possible to choose the timezone of the command execution by setting the `SYNOLIA_SCHEDULER_PLUGIN_TIMEZONE` environment variable, example: | ||||||
|
|
||||||
| ``` | ||||||
| SYNOLIA_SCHEDULER_PLUGIN_TIMEZONE=Europe/Paris | ||||||
| ``` | ||||||
|
|
||||||
| ### synolia:scheduler:purge-history | ||||||
|
|
||||||
| Purge scheduled command history greater than {X} days old. | ||||||
|
|
||||||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,69 @@ | ||
| <?php | ||
|
|
||
| declare(strict_types=1); | ||
|
|
||
| namespace Synolia\SyliusSchedulerCommandPlugin\EventSubscriber; | ||
|
|
||
| use Doctrine\DBAL\Exception; | ||
| use Symfony\Component\Console\ConsoleEvents; | ||
| use Symfony\Component\Console\Event\ConsoleSignalEvent; | ||
| use Symfony\Component\Console\Event\ConsoleTerminateEvent; | ||
| use Symfony\Component\EventDispatcher\EventSubscriberInterface; | ||
| use Synolia\SyliusSchedulerCommandPlugin\Entity\ScheduledCommand; | ||
| use Synolia\SyliusSchedulerCommandPlugin\Enum\ScheduledCommandStateEnum; | ||
| use Synolia\SyliusSchedulerCommandPlugin\Repository\ScheduledCommandRepository; | ||
|
|
||
| final class ConsoleSubscriber implements EventSubscriberInterface | ||
| { | ||
| public function __construct( | ||
| private readonly ScheduledCommandRepository $scheduledCommandRepository, | ||
| ) { | ||
| } | ||
|
|
||
| public static function getSubscribedEvents(): array | ||
| { | ||
| return [ | ||
| ConsoleEvents::TERMINATE => 'onConsoleTerminate', | ||
| ConsoleEvents::SIGNAL => 'onConsoleSignal', | ||
| ]; | ||
| } | ||
|
|
||
| public function onConsoleTerminate(ConsoleTerminateEvent $event): void | ||
| { | ||
| $this->updateCommand($event); | ||
| } | ||
|
|
||
| public function onConsoleSignal(ConsoleSignalEvent $event): void | ||
| { | ||
| $this->updateCommand($event); | ||
| } | ||
|
|
||
| private function updateCommand(ConsoleSignalEvent|ConsoleTerminateEvent $event): void | ||
| { | ||
| try { | ||
| $commandCode = $event->getCommand()?->getName() ?? 'no_command'; | ||
| /** @var ScheduledCommand|null $schedulerCommand */ | ||
| $schedulerCommand = $this->scheduledCommandRepository->findOneBy(['command' => $commandCode], ['id' => 'DESC']); | ||
| } catch (Exception) { | ||
| return; | ||
| } | ||
|
|
||
| if (null === $schedulerCommand) { | ||
| return; | ||
| } | ||
|
|
||
| if ($schedulerCommand->getState() !== ScheduledCommandStateEnum::IN_PROGRESS) { | ||
| return; | ||
| } | ||
|
|
||
| $exitCode = $event->getExitCode(); | ||
| if (false === $exitCode) { | ||
| $exitCode = -1; | ||
| } | ||
|
|
||
| $schedulerCommand->setCommandEndTime(new \DateTime()); | ||
| $schedulerCommand->setState(ScheduledCommandStateEnum::TERMINATION); | ||
| $schedulerCommand->setLastReturnCode($exitCode); | ||
| $this->scheduledCommandRepository->add($schedulerCommand); | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,32 @@ | ||
| <?php | ||
|
|
||
| declare(strict_types=1); | ||
|
|
||
| namespace Synolia\SyliusSchedulerCommandPlugin\Provider; | ||
|
|
||
| use DateTimeImmutable; | ||
| use DateTimeZone; | ||
| use Exception; | ||
| use Sylius\Calendar\Provider\DateTimeProviderInterface; | ||
| use Symfony\Component\DependencyInjection\Attribute\AsAlias; | ||
| use Symfony\Component\DependencyInjection\Attribute\Autowire; | ||
|
|
||
| #[AsAlias(DateTimeProviderInterface::class)] | ||
| final class CalendarWithTimezone implements DateTimeProviderInterface | ||
| { | ||
| public function __construct( | ||
| #[Autowire(param: 'env(SYNOLIA_SCHEDULER_PLUGIN_TIMEZONE)')] | ||
| private ?string $timezone = null, | ||
| ) { | ||
| } | ||
|
|
||
| /** | ||
| * @throws Exception | ||
| */ | ||
| public function now(): \DateTimeInterface | ||
| { | ||
| $timezone = $this->timezone ?? date_default_timezone_get(); | ||
|
|
||
| return new DateTimeImmutable(timezone: new DateTimeZone($timezone)); | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,30 +1,24 @@ | ||
| {% extends '@SyliusAdmin/layout.html.twig' %} | ||
|
|
||
| {% import '@SyliusUi/Macro/headers.html.twig' as headers %} | ||
|
|
||
| {% block title %}{{ 'synolia.ui.live_view_of_scheduled_command'|trans({'%scheduledCommandName%': scheduledCommand.name|e}) }} {{ parent() }}{% endblock %} | ||
|
|
||
| {% block content %} | ||
| {{ headers.default('synolia.ui.live_view_of_scheduled_command'|trans({'%scheduledCommandName%': scheduledCommand.name|e}), 'cogs') }} | ||
|
|
||
| <div class="ui input"> | ||
| <input id="grep" type="text" placeholder="Search..."> | ||
| </div> | ||
| <div class="ui icon input"> | ||
| <input id="grep" type="text" placeholder="Search..."> | ||
| <i class="search icon"></i> | ||
| </div> | ||
|
|
||
| <div id="log-results"> | ||
| <pre id="results"> | ||
| <div class="ui active centered inline loader"></div> | ||
| </pre> | ||
| </div> | ||
|
|
||
| {{ sylius_template_event('synolia.admin.command.logs.stylesheets') }} | ||
|
|
||
| {{ sylius_template_event('synolia.admin.command.logs.stylesheets') }} | ||
| <script type="text/javascript"> | ||
| {% autoescape 'js' %} | ||
| /* <![CDATA[ */ | ||
| var sy_updateTime = {{ updateTime }}; | ||
| var sy_route = "{{ route }}"; | ||
| /* ]]> */ | ||
| {% endautoescape %} | ||
| </script> | ||
|
|
||
| <script type="text/javascript"> | ||
| {% autoescape 'js' %} | ||
| /* <![CDATA[ */ | ||
| var sy_updateTime = {{ updateTime }}; | ||
| var sy_route = "{{ route }}"; | ||
| /* ]]> */ | ||
| {% endautoescape %} | ||
| </script> | ||
| {{ sylius_template_event('synolia.admin.command.logs.javascripts') }} | ||
|
|
||
| {{ sylius_template_event('synolia.admin.command.logs.javascripts') }} | ||
| {% endblock %} |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i'm wondering if
composer reqdoes not already play this command at auto-scripts 🤔