synolia/sylius-scheduler-command-plugin

Scheduler Command Plugin.

Installs: 32 541

Dependents: 0

Suggesters: 0

Security: 0

Stars: 18

Watchers: 12

Forks: 12

Open Issues: 2

Type:sylius-plugin

v4.0.0 2021-04-16 12:47 UTC

This package is auto-updated.

Last update: 2021-09-28 15:15:25 UTC


README

License Tests Version Total Downloads

68747470733a2f2f64656d6f2e73796c6975732e636f6d2f6173736574732f73686f702f696d672f6c6f676f2e706e67

Scheduler Command Plugin

68747470733a2f2f73796c6975732e636f6d2f6173736574732f62616467652d617070726f7665642d62792d73796c6975732e706e67

Schedule Symfony Commands in your Sylius admin panel.

Commands list

Commands

Scheduled Commands list

Scheduled Commands

Features

  • See the list of planned command
  • Add, edit, enable/disable or delete scheduled commands
  • For each command, you have to define :
    • Name
    • Selected Command from the list of Symfony commands
    • Based on Cron schedule expression see Cron formats
    • Output Log file prefix (optional)
    • Priority (highest is priority)
  • Run the Command immediately (at the next passage of the command synolia:scheduler-run)
  • Run a Command juste one time (from history page clic on Launch a command button)
  • Download or live view of log files directly from the admin panel
  • Define commands with a Factory (from a Doctrine migration, for example)

Requirements

Version
PHP 7.4, 8.0
Sylius 1.8, 1.9, 1.10

Installation

  1. Add the bundle and dependencies in your composer.json :

     composer config extra.symfony.allow-contrib true
     composer req synolia/sylius-scheduler-command-plugin
    
  2. Apply migrations to your database:

     bin/console doctrine:migrations:migrate
    
  3. Launch Run command in your Crontab

     * * * * * /_PROJECT_DIRECTORY_/bin/console synolia:scheduler-run
    
  4. (optional) Showing humanized cron expression

     composer require dragonmantank/cron-expression
    

Usage

  • Log into admin panel
  • Click on Scheduled commands in the Scheduled commands section in main menu to manage your Scheduled commands
  • Click on Scheduled commands history in the Scheduled commands section in main menu to see history of commands

Fixtures

Inside sylius fixture file config/packages/sylius_fixtures.yaml you can add scheduled command fixtures to your suite.

sylius_fixtures:
    suites:
        my_fixture_suite:
            fixtures:
                scheduler_command:
                    options:
                        scheduled_commands:
                            -
                                name: 'Reset Sylius'
                                command: 'sylius:fixtures:load'
                                cronExpression: '0 0 * * *'
                                logFilePrefix: 'reset'
                                priority: 0
                                enabled: true
                            -
                                name: 'Cancel Unpaid Orders'
                                command: 'sylius:cancel-unpaid-orders'
                                cronExpression: '0 0 * * *'
                                priority: 1
                                enabled: false

Optional services

services:
...
    # By enabling this service, it will be requested to vote after the other EveryMinuteIsDueChecker checker.
    # Using some cloud providers, even if the master cron is set to run every minute, it is actually not run that often
    # This service allows you to set a soft threshold limit, so if your provider is actually running the master cron every 5 minutes
    # This service will execute the cron if we are still in the threshold limit ONLY IF it was not already executed another time in the same range.
    #
    # CONFIGURATION SCENARIO: cron set to be run at 01:07 in the scheduler command plugin
    #
    # SCENARIO CASES AT 1 CRON PASS EVERY 5 MINUTES FROM THE PROVIDER
    # cron passes at 01:04 - 1..5 minutes: IS NOT DUE
    # cron passes at 01:05 - 1..5 minutes: IS NOT DUE
    # cron passes at 01:06 - 1..5 minutes: IS NOT DUE
    # cron passes at 01:07 - 1..5 minutes: IS DUE (but it should already be handled by EveryMinuteIsDueChecker)
    # cron passes at 01:08 - 1..5 minutes: IS DUE
    # cron passes at 01:09 - 1..5 minutes: IS DUE #should not if another has started during the threshold period
    # cron passes at 01:10 - 1..5 minutes: IS DUE #should not if another has started during the threshold period
    # cron passes at 01:11 - 1..5 minutes: IS DUE #should not if another has started during the threshold period
    # cron passes at 01:12 - 1..5 minutes: IS DUE #should not if another has started during the threshold period
    # cron passes at 01:13 - 1..5 minutes: IS NOT DUE
    Synolia\SyliusSchedulerCommandPlugin\Checker\SoftLimitThresholdIsDueChecker:
        tags:
            - { name: !php/const Synolia\SyliusSchedulerCommandPlugin\Checker\IsDueCheckerInterface::TAG_ID }
        #optionnal, default value is 5 minutes
        arguments:
            $threshold: 5 #soft limit threshold in minutes

Development

See How to contribute.

License

This library is under the MIT license.

Credits

Developed by Synolia.