Uploaded image for project: 'Blesta Core'
  1. Blesta Core
  2. CORE-2435

Allow modules to create their own automation tasks

    Details

    • Type: Story
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 4.0.0
    • Fix Version/s: 4.3.0-b1
    • Component/s: None
    • Labels:
      None

      Description

      1. Add a new optional feature for modules to support an automation method that may be called at a given interval by Blesta cron
        • Allow Input errors to be set? And if they are, include them in the cron log? Or simply assume the module will write errors to monolog?
      2. Add a new core cron task to call the automation method on all installed modules

      Things to consider:

      1. Modules are much similar to plugins now, and differentiating them while merging similar features may require refactoring (something to do in a major release)
      2. Modules need database access. Loading the Record component may not suffice, and an instance of it may need to be provided instead
      3. Logging mechanisms may need to be provided to the module and its automation task
      4. Backward compatibility must be maintained
      5. Modules may need more flexibility with automation tasks, such as better support for running multiple tasks, or knowledge of the last time a particular task was last run (like a normal cron task). It would not have this information unless it creates database tables and maintains it itself.
        • It may need to integrate similar install/upgrade/uninstall functionality as plugins

      TODO:

      1. Update Modules to support a new method, cron($key), similar to plugins. Default to do nothing
      2. Refactor CronTasks and the `plugin_dir` column to support modules
        • Add a `type` column, ENUM(system, plugin, module), default system, after `key`
        • Rename the `plugin_dir` column to `dir`.
        • Update the unique index for (`key`, `plugin_dir`) to (`key`, `type`, `dir`)
      3. Update for backward compatibility
        • Update all returned objects to contain a 'plugin_dir' column. If `type` is 'plugin' then set 'plugin_dir' to the value of 'dir', otherwise null. TEST
        • Update existing CronTasks methods and queries that use 'plugin_dir' to continue to work as before. TEST
        • Add any new methods necessary to implement the same functionality on the new structure. Deprecate existing methods accordingly. TEST
        • Update all core system calls to CronTasks to use the new methods. TEST
        • (Create new tasks for each core plugin that uses cron tasks to update them accordingly)
      4. Add a new task when the cron runs for running module tasks, similar to plugin cron tasks. TEST

      Consider allowing modules to create their own automation tasks. Such automation tasks could call methods within the module that registers the automation task to perform some action.

      Or, maybe this could be abstracted such that there is a built in module automation task that calls such methods within each module on a regular basis so the module can perform such actions if it desires.

      Requires some discussion

      See https://www.blesta.com/forums/index.php?/topic/4032-allow-modules-to-add-cron-tasks/&tab=comments#comment-54670

        Activity

          People

          • Assignee:
            tyson Tyson Phillips (Inactive)
            Reporter:
            admin Paul Phillips
          • Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:
              Fix Release Date:
              15/Jun/18

              Time Tracking

              Estimated:
              Original Estimate - Not Specified
              Not Specified
              Remaining:
              Remaining Estimate - 0 minutes
              0m
              Logged:
              Time Spent - 1 day, 5 hours, 40 minutes
              1d 5h 40m

                Agile