Skip to content

Commit

Permalink
Merged in PG-356-October-16-Modules-Update (pull request civicrm#15)
Browse files Browse the repository at this point in the history
PGFF-14: elysia_cron-7.x-2.3 update
  • Loading branch information
vincent1892 committed Nov 14, 2016
2 parents 0432a1b + 7c88a23 commit 8b940af
Show file tree
Hide file tree
Showing 23 changed files with 3,461 additions and 2,659 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ You can use the "hook_cron_alter" function to edit cronapi data of other
modules.

Example:
function module_cron_alter($data) {
function module_cron_alter(&$data) {
$data['key']['rule'] = '0 */6 * * *';
}

Expand Down Expand Up @@ -182,6 +182,19 @@ function phptemplate_elysia_cron_description($job) {
Note: module default theme_elysia_cron_description($job) already contains
some common tasks descriptions.

-----------------------------------------------------------------------------
DISABLE CRON JOBS VIA settings.php FILE
-----------------------------------------------------------------------------
If you have some instances for the project you can want to disable some cron
jobs on different instances. For example you don't want to execute PROD cron
jobs on DEV instance. There is no need to make it via interface or via SQL
query. You can define variable for each cron job to manage it state. For more
information please look at `_elysia_cron_is_job_disabled` and `_ec_get_name`
functions.

For example, if you have cron job with name googleanalytics_cron, you can
add this string to your settings.php file:
$conf['ec_googleanalytics_cron_d'] = TRUE;

-----------------------------------------------------------------------------
OLD 1.x MODULE API (OBSOLETE)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,7 @@ up and running.
You can stop here if you don't need a great precision over task execution and
you don't have to execute a task more often than once an hour.
For example, if you need only the "Once a day", "Once a week" or "Once a month"
schedule rules the basic install is fine. (For D6 users that want to stop here:
you should have installed Drupal crontab as described in Drupal INSTALL guide).
schedule rules the basic install is fine.

Instead, if you need:
- to run some tasks more often than once an hour (eg: you have a function that
Expand All @@ -41,8 +40,8 @@ The only difference is that you should use the "* * * * *" rule part instead of
"0 * * * *" or "45 * * * *" as described in the guide.

While you're editing the system crontab, it's also recommended to replace the
"/cron.php" part with "/sites/modules/elysia_cron/cron.php" (if you have
installed elysia_cron in "sites/modules" directory).
"/cron.php" part with "/sites/all/modules/elysia_cron/cron.php" (if you have
installed elysia_cron in "sites/all/modules" directory).
This is an optional step (you can leave "/cron.php" if you want), doing it will
result in a better performance in bigger sites (elysia_cron's cron.php handles
cache in a better way).
Expand Down Expand Up @@ -78,6 +77,10 @@ red; font-weight: bold; }
PERMISSIONS
------------

You can also give 'administer elysia_cron' permission to all user roles that
needs to administer cron jobs. You can do this with standard drupal users
administration.
There are three permission provided by module:
* Administer elysia cron - Perform changes to cron jobs timings, disable cron
or single jobs and access cron execution statistics;
* Execute elysia cron jobs - Allow users to view statistics, execution status
and do manually execute cron jobs;
* View elysia cron stats - Allows users to view statistics and execution status
of cron jobs;
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -9,27 +9,27 @@ For module developers API documetation read API.TXT
FEATURES
-----------------------------------------------------------------------------

Elysia Cron extends Drupal standard cron, allowing a fine grain control over
Elysia Cron extends Drupal standard cron, allowing a fine grain control over
each task and several ways to add custom cron jobs to your site.

- Set the timings and frequencies of each cron task (you can run some jobs every
day at a specified hour, other only monthly and so on...).
For each task you can simply choose between some frequently used options
("once a day", "once a month" ...), or use a powerful "linux crontab"-like
syntax to set the accurate timings. You can even define your frequently used
For each task you can simply choose between some frequently used options
("once a day", "once a month" ...), or use a powerful "linux crontab"-like
syntax to set the accurate timings. You can even define your frequently used
options to speed up site configuration.
- Parallel execution of cron task: you can group jobs in channels and execute
- Parallel execution of cron task: you can group jobs in channels and execute
then simultaneously: so a task that takes a lot of time to execute won't block
other tasks that need to be executed every 5 minutes...
- You can disable all tasks, an entire channel or a single task.
- Change the priority/order of task execution.
- Manual force the execution of a cron tasks.
- Detailed overview of cron status with time statistics for single tasks and
- Detailed overview of cron status with time statistics for single tasks and
channels.

- Powerful API for module developers: you can define extra cron tasks for your
modules, each one with own default timings (site administrators can override
them by configuration, other modules via hook_alter). Elysia Cron 2.0 gives a
- Powerful API for module developers: you can define extra cron tasks for your
modules, each one with own default timings (site administrators can override
them by configuration, other modules via hook_alter). Elysia Cron 2.0 gives a
brand new API support (compatible with 1.0 version) with a lot of features.
- Administrators can define custom jobs (call to functions with parameters), via
the "script" option.
Expand All @@ -43,7 +43,7 @@ It also can be used in a Drupal install profile.
3rd party integration:
- Ping feature, for external tracking services like host-tracker to tell whether
cron is functioning properly on your site.
- Drush support: you can call "drush elysia-cron" to manually run extended cron.
- Drush support: you can call "drush elysia-cron run" to manually run extended cron.
- CTools support for exports/backup of task settings.
- Features support.

Expand All @@ -53,35 +53,35 @@ USAGE EXAMPLES

Elysia cron is usually used in large sites that needs performance optimization.

- Avoid drupal peak loads by distributing heavy load tasks during quiet periods
of the day: for example you may want to rebuild the XML Sitemap of your site
at 2:00AM in the morning, where usually only a few people are visiting your
site. You can even move some tasks to be executed only once a month (log
- Avoid drupal peak loads by distributing heavy load tasks during quiet periods
of the day: for example you may want to rebuild the XML Sitemap of your site
at 2:00AM in the morning, where usually only a few people are visiting your
site. You can even move some tasks to be executed only once a month (log
rotation, old records expiry...).

- If you have tasks that should be executed very often, but don't want to
execute ALL drupal cron tasks that often! For example, you may want to check
for emails that needs to be sent to your users every 2 minutes. Standard cron
is managed in a "monolithic" way, so even if you find out how to execute it
- If you have tasks that should be executed very often, but don't want to
execute ALL drupal cron tasks that often! For example, you may want to check
for emails that needs to be sent to your users every 2 minutes. Standard cron
is managed in a "monolithic" way, so even if you find out how to execute it
every 2 minutes, you will end in having all cron tasks executed so often, with
a lot of performance problems.

- Fine tune cron cache management : drupal cron will invalidate variable cache
every cron run, and this is a great performance problem if you have a
frequently called task. Elysia cron optimize cache management, and doesn't
- Fine tune cron cache management : drupal cron will invalidate variable cache
every cron run, and this is a great performance problem if you have a
frequently called task. Elysia cron optimize cache management, and doesn't
need to invalidate cache.

- Setup tasks that should be run at a precise time: for example if you want to
- Setup tasks that should be run at a precise time: for example if you want to
send a SimpleNews newsletter every monday at 9:00AM, you can do it.

- Parallel execution: if you have a task that takes a lot of time to execute,
you can setup a different channel for it so it won't block other tasks that
- Parallel execution: if you have a task that takes a lot of time to execute,
you can setup a different channel for it so it won't block other tasks that
need to be executed every 5 minutes.

- Turn off (disable) a cron task/feature you don't need.

- Debug system cron problems. If your cron does not terminate correctly you can
use extended logging, see at each cron timings and disable task to track down
use extended logging, see at each cron timings and disable task to track down
the problem.

-----------------------------------------------------------------------------
Expand All @@ -93,11 +93,11 @@ Channels are groups of tasks. Each channel is a "parallel line" of execution
Tasks inside a channel will be executed sequentially (if they should).

WARNING: It's not recommended to create more than 2 or 3 channels.
Every channel will increase the delay between each cron check (of the same
Every channel will increase the delay between each cron check (of the same
channel), because each cron call will cycle between all channels.
So, for example:
If you have 1 channel it will be checked once a minute.
If you have 2 channel each one will be checked every 2 minutes (almost usually,
If you have 2 channel each one will be checked every 2 minutes (almost usually,
when the other one is running it will be checked once a minute).
It you have 10 channels there will be a check every 10 minutes... if you have
a job that should be executed every 5 minutes it won't do so!
Expand All @@ -106,18 +106,18 @@ a job that should be executed every 5 minutes it won't do so!
EXPORT VIA CTOOLS/FEATURES MODULE
-----------------------------------------------------------------------------

With 2.0 version of Elysia Cron you can use "Bulk Export" functionality of
With 2.0 version of Elysia Cron you can use "Bulk Export" functionality of
"Chaos Tools Suite" to export cron settings.
To use it simply enable all modules, go to Structure > Bulk Exporter and
select the tasks you want to export settings. You can also select all
select the tasks you want to export settings. You can also select all
"elysia_cron" prefixed variables to export global options.
Than generate the module.

The generated code will set the new defaults of elysia cron settings. This way
you can simply enable it to use them, but you are free to override them in
the future using the normal settings page.
Note that if you want to delete all overrides, and return to exported settings,
you should do a "reset to defaults" from elysia cron settings page.
you should do a "reset to defaults" from elysia cron settings page.

You can also use "Features" module to create a Feature module will the settings
you need.
Expand All @@ -133,7 +133,32 @@ DRUSH SUPPORT

Elysia Cron 2.0 adds a simple support for Drush module.

You can execute the "elysia-cron" command to run cron.
Run all cron tasks in all active modules for specified site using elysia cron
system. This replaces the standard "core-cron" drush handler.

Examples:
elysia-cron run Run all cron tasks in all active
modules (as the standard "core-cron")
elysia-cron run --verbose Run all cron tasks in verbose mode
elysia-cron run @channel Run all cron tasks in specified
channel
elysia-cron run search_cron --ignore-time Run only search index
build task (force execution)
elysia-cron list --elysia-cron-verbose List all channels/tasks
in verbose mode
elysia-cron disable search_cron Disable search index build task

Options:
--elysia-cron-verbose enable extended output (the same as
--verbose, but without enabling drush
verbose mode)
--ignore-disable run channels/tasks even if disabled
--ignore-running run channels/tasks even
if already running
--ignore-time run channels/tasks even if not ready
for execution
--quiet suppress all output
--verbose enable extended output

-----------------------------------------------------------------------------
RULES AND SCRIPT SYNTAX
Expand All @@ -150,17 +175,17 @@ RULES AND SCRIPT SYNTAX
| | | | |
* * * * *

Each of the patterns from the first five fields may be either * (an asterisk),
which matches all legal values, or a list of elements separated by commas
Each of the patterns from the first five fields may be either * (an asterisk),
which matches all legal values, or a list of elements separated by commas
(see below).

For "day of the week" (field 5), 0 is considered Sunday, 6 is Saturday (7 is
For "day of the week" (field 5), 0 is considered Sunday, 6 is Saturday (7 is
an illegal value)

A job is executed when the time/date specification fields all match the current
time and date. There is one exception: if both "day of month" and "day of week"
are restricted (not "*"), then either the "day of month" field (3) or the "day
of week" field (5) must match the current day (even though the other of the two
A job is executed when the time/date specification fields all match the current
time and date. There is one exception: if both "day of month" and "day of week"
are restricted (not "*"), then either the "day of month" field (3) or the "day
of week" field (5) must match the current day (even though the other of the two
fields need not match the current day).

2. FIELDS OPERATOR
Expand All @@ -169,13 +194,13 @@ fields need not match the current day).
There are several ways of specifying multiple date/time values in a field:

* The comma (',') operator specifies a list of values, for example: "1,3,4,7,8"
* The dash ('-') operator specifies a range of values, for example: "1-6", which
* The dash ('-') operator specifies a range of values, for example: "1-6", which
is equivalent to "1,2,3,4,5,6"
* The asterisk ('*') operator specifies all possible values for a field. For
example, an asterisk in the hour time field would be equivalent to 'every hour'
* The asterisk ('*') operator specifies all possible values for a field. For
example, an asterisk in the hour time field would be equivalent to 'every hour'
(subject to matching other specified fields).
* The slash ('/') operator (called "step") can be used to skip a given number of
values. For example, "*/3" in the hour time field is equivalent to
* The slash ('/') operator (called "step") can be used to skip a given number of
values. For example, "*/3" in the hour time field is equivalent to
"0,3,6,9,12,15,18,21".

3. EXAMPLES
Expand All @@ -190,10 +215,10 @@ There are several ways of specifying multiple date/time values in a field:
4. SCRIPTS
---------------------------------

You can use the script section to easily create new jobs (by calling a php
You can use the script section to easily create new jobs (by calling a php
function) or to change the scheduling of an existing job.

Every line of the script can be a comment (if it starts with #) or a job
Every line of the script can be a comment (if it starts with #) or a job
definition.

The syntax of a job definition is:
Expand All @@ -207,10 +232,10 @@ The syntax of a job definition is:
* [job]: could be the name of a supported job (for example: 'search_cron') or a
function call, ending with ; (for example: 'process_queue();').

A comment on the line just preceding a job definition is considered the job
A comment on the line just preceding a job definition is considered the job
description.

Remember that script OVERRIDES all settings on single jobs sections or channel
Remember that script OVERRIDES all settings on single jobs sections or channel
sections of the configuration

5. EXAMPLE OF SCRIPT
Expand All @@ -219,7 +244,7 @@ sections of the configuration
# Search indexing every 2 hours (i'm setting this as the job description)
0 */2 * * * search_cron

# I'll check for module status only on sunday nights
# I'll check for module status only on sunday nights
# (and this is will not be the job description, see the empty line below)

0 2 * * 0 update_status_cron
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,11 @@
if (!file_exists('includes/bootstrap.inc')) {
if (!empty($_SERVER['DOCUMENT_ROOT']) && file_exists($_SERVER['DOCUMENT_ROOT'] . '/includes/bootstrap.inc')) {
chdir($_SERVER['DOCUMENT_ROOT']);
} elseif (preg_match('@^(.*)[\\\\/]sites[\\\\/][^\\\\/]+[\\\\/]modules[\\\\/]([^\\\\/]+[\\\\/])?elysia(_cron)?$@', getcwd(), $r) && file_exists($r[1] . '/includes/bootstrap.inc')) {
}
elseif (preg_match('@^(.*)[\\\\/]sites[\\\\/][^\\\\/]+[\\\\/]modules[\\\\/]([^\\\\/]+[\\\\/])?elysia(_cron)?$@', getcwd(), $r) && file_exists($r[1] . '/includes/bootstrap.inc')) {
chdir($r[1]);
} else {
}
else {
die("Cron Fatal Error: Can't locate bootstrap.inc. Check cron.php position.");
}
}
Expand All @@ -21,16 +23,14 @@
define('DRUPAL_ROOT', getcwd());

include_once DRUPAL_ROOT . '/includes/bootstrap.inc';
drupal_override_server_variables(array(
'SCRIPT_NAME' => '/cron.php',
));
drupal_override_server_variables(array('SCRIPT_NAME' => '/cron.php'));
drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);

if (!isset($_GET['cron_key']) || variable_get('cron_key', 'drupal') != $_GET['cron_key']) {
if ((variable_get('cron_key') && empty($_GET['cron_key'])) || !empty($_GET['cron_key']) && variable_get('cron_key') != $_GET['cron_key']) {
watchdog('cron', 'Cron could not run because an invalid key was used.', array(), WATCHDOG_NOTICE);
drupal_access_denied();
}
elseif (variable_get('maintenance_mode', 0)) {
elseif (variable_get('maintenance_mode', 0) && !variable_get('elysia_cron_run_maintenance', FALSE)) {
watchdog('cron', 'Cron could not run because the site is in maintenance mode.', array(), WATCHDOG_NOTICE);
drupal_access_denied();
}
Expand Down
Loading

0 comments on commit 8b940af

Please sign in to comment.