-
Notifications
You must be signed in to change notification settings - Fork 74
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
17 changed files
with
435 additions
and
44 deletions.
There are no files selected for viewing
This file contains 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 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,12 +1,14 @@ | ||
# SilverStripe Queued Jobs Module | ||
|
||
[![Build Status](https://travis-ci.org/symbiote/silverstripe-queuedjobs.svg?branch=master)](https://travis-ci.org/symbiote/silverstripe-queuedjobs) | ||
[![Scrutinizer](https://scrutinizer-ci.com/g/symbiote/silverstripe-queuedjobs/badges/quality-score.png)](https://scrutinizer-ci.com/g/symbiote/silverstripe-queuedjobs/) | ||
|
||
|
||
## Maintainer Contact | ||
|
||
Marcus Nyeholt | ||
|
||
marcus@symbiote.com.au | ||
<marcus (at) symbiote (dot) com (dot) au> | ||
|
||
## Requirements | ||
|
||
|
@@ -128,6 +130,83 @@ Note - if you do NOT have this running, make sure to set `QueuedJobService::$use | |
so that immediate mode jobs don't stall. By setting this to true, immediate jobs will be executed after | ||
the request finishes as the php script ends. | ||
|
||
# Default Jobs | ||
|
||
Some jobs should always be either running or queued to run, things like data refreshes or periodic clean up jobs, we call these Default Jobs. | ||
Default jobs are checked for at the end of each job queue process, using the job type and any fields in the filter to create an SQL query e.g. | ||
|
||
``` | ||
ArbitraryName: | ||
type: 'ScheduledExternalImportJob' | ||
filter: | ||
JobTitle: 'Scheduled import from Services' | ||
``` | ||
Will become: | ||
``` | ||
QueuedJobDescriptor::get()->filter(array( | ||
'type' => 'ScheduledExternalImportJob', | ||
'JobTitle' => 'Scheduled import from Services' | ||
)); | ||
``` | ||
This query is checked to see if there's at least 1 healthly (new, run, wait or paused) job matching the filter. If there's not and recreate is true in the yml config we use the construct array as params to pass to a new job object e.g: | ||
``` | ||
ArbitraryName: | ||
type: 'ScheduledExternalImportJob' | ||
filter: | ||
JobTitle: 'Scheduled import from Services' | ||
recreate: 1 | ||
construct: | ||
repeat: 300 | ||
contentItem: 100 | ||
target: 157 | ||
``` | ||
If the above job is missing it will be recreated as: | ||
``` | ||
Injector::inst()->createWithArgs('ScheduledExternalImportJob', $construct[]) | ||
``` | ||
### Pausing Default Jobs | ||
If you need to stop a default job from raising alerts and being recreated, set an existing copy of the job to Paused in the CMS. | ||
### YML config | ||
Default jobs are defined in yml config the sample below covers the options and expected values | ||
``` | ||
Injector: | ||
QueuedJobService: | ||
properties: | ||
defaultJobs: | ||
# This key is used as the title for error logs and alert emails | ||
ArbitraryName: | ||
# The job type should be the class name of a job REQUIRED | ||
type: 'ScheduledExternalImportJob' | ||
# This plus the job type is used to create the SQL query REQUIRED | ||
filter: | ||
# 1 or more Fieldname: 'value' sets that will be queried on REQUIRED | ||
# These can be valid ORM filter | ||
JobTitle: 'Scheduled import from Services' | ||
# Sets whether the job will be recreated or not OPTIONAL | ||
recreate: 1 | ||
# Set the email address to send the alert to if not set site admin email is used OPTIONAL | ||
email: '[email protected]' | ||
# Parameters set on the recreated object OPTIONAL | ||
construct: | ||
# 1 or more Fieldname: 'value' sets be passed to the constructor OPTIONAL | ||
repeat: 300 | ||
title: 'Scheduled import from Services' | ||
# Minimal implementation will send alerts but not recreate | ||
AnotherTitle: | ||
type: 'AJob' | ||
filter: | ||
JobTitle: 'A job' | ||
``` | ||
## Configuring the CleanupJob | ||
By default the CleanupJob is disabled. To enable it, set the following in your YML: | ||
|
This file contains 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 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 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 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 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 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 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,57 @@ | ||
ru: | ||
CreateQueuedJobTask: | ||
Description: 'Задача используется для создания отложенного действия. Укажите тип задачи, укажите опциональный параметр "start" (обрабатывается функцией strtotime) для времени начала.' | ||
DeleteObjectJob: | ||
DELETE_JOB: Удалить | ||
DELETE_OBJ2: 'Удалить {title}' | ||
GenerateSitemapJob: | ||
REGENERATE: 'Генерировать Google sitemap .xml файл' | ||
ProcessJobQueueTask: | ||
Description: 'Используется cron для выполнения отложенных задач.' | ||
PublishItemsJob: | ||
Title: 'Опубликовать вложенные объекты {title}' | ||
QueuedJobDescriptor: | ||
PLURALNAME: 'Дескрипторы отложенных задач' | ||
SINGULARNAME: 'Дескриптор отложенной задачи' | ||
QueuedJobRule: | ||
PLURALNAME: 'Настройки отложенных задач' | ||
SINGULARNAME: 'Настройки отложенной задачи' | ||
QueuedJobs: | ||
CREATE_JOB_TYPE: 'Создать задачу типа' | ||
CREATE_NEW_JOB: 'Создать задачу' | ||
JOB_EXCEPT: 'Произошла ошибка задачи %s в %s на строчке %s' | ||
JOB_PAUSED: 'Задача остановлена %s' | ||
JOB_STALLED: 'Задача замороженна после %s попыток - пожалуйста проверьте' | ||
JOB_TYPE: 'Тип задачи' | ||
JOB_TYPE_PARAMS: 'Параметры конструктора задачи' | ||
JobsFieldTitle: Задачи | ||
MEMORY_RELEASE: 'Задача ожидает освобождения памяти (%s использовано)' | ||
STALLED_JOB: 'Замороженная задача' | ||
STALLED_JOB_MSG: 'Задача %s заморожена. Задача была остановлена, войдите в систему для проверки' | ||
START_JOB_TIME: 'Начать задачу в' | ||
TABLE_ADDE: Добавлена | ||
TABLE_MESSAGES: Сообщение | ||
TABLE_NUM_PROCESSED: Выполнено | ||
TABLE_STARTED: Начата | ||
TABLE_START_AFTER: 'Начать после' | ||
TABLE_STATUS: Статус | ||
TABLE_TITLE: Название | ||
TABLE_TOTAL: Итого | ||
TIME_LIMIT: 'Очередь достигла лимита по времени и будет начата заново перед продолжением' | ||
QueuedJobsAdmin: | ||
MENUTITLE: Задачи | ||
ScheduledExecution: | ||
EXECUTE_EVERY: 'Выполнять каждые' | ||
EXECUTE_FREE: 'Запланировано (в формате strtotime после первого выполнения)' | ||
ExecuteEveryDay: День | ||
ExecuteEveryFortnight: 'Две недели' | ||
ExecuteEveryHour: Час | ||
ExecuteEveryMinute: Минута | ||
ExecuteEveryMonth: Месяц | ||
ExecuteEveryWeek: Неделя | ||
ExecuteEveryYear: Год | ||
FIRST_EXECUTION: 'Первое исполнение' | ||
NEXT_RUN_DATE: 'Дата следующего исполнения' | ||
ScheduleTabTitle: 'Расписание' | ||
ScheduledExecutionJob: | ||
Title: 'Запланировано исполнение {title}' |
This file contains 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 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
Oops, something went wrong.