Package: collective.warmup
Introductioncollective.warmup has been created to warm up web application’s caches upon
start and restart.It works by reading a configuration file containing a list of urls that
are then invoked.collective.warmup is inspired by Gil Forcada’swarmup_plone.pyscript.Why not a simple bash script?While the basic use case is very simple,
collective.warmup offers the following extra features:Verifies the correctness of the response body (e.g. contains a certain string)Can operate incrawl mode,
following links in pages to warm up all related pagesCan filter out certain urls according to a general definitionInstallationcollective.warmup can be installed in two ways:As a normal python package via pipInside abuildout, with optional integration withPloneDependencieslxmlManual installationTo install it (usingvirtualenv, on a GNU/Debian machine):$ sudo apt-get install build-essential python-dev python-lxml python-virtualenv libxml2-dev libxslt1-dev
$ virtualenv warmup && cd warmup && souce bin/activate
(warmup) $ pip install collective.warmupand launch it with:(warmup) $ bin/warmup <path/file.ini>Alternative installation with buildoutTo integrate collective.warmup in abuildoutwithPlone,
add this to your configuration:[buildout]
...
parts =
    ...
    warmup


[instance]
...
eggs +=
    collective.warmup


[instance]
environment-vars +=
    WARMUP_BIN ${buildout:directory}/bin/warmup
    WARMUP_INI ${buildout:directory}/warmup.ini
    WARMUP_HEALTH_THRESHOLD 50000


[warmup]
recipe = zc.recipe.egg:scripts
eggs = collective.warmupAfter executing the buildout you will find the warmup script
in thebindirectory.In this example, the script will be executed automatically
by theZopeinstance each time it is started.Configuration fileThis is a samplewarmup.iniconfiguration:[warmup]
enabled = True
sleep = 2
base_url = http://localhost
logfile = /path/to/warmup.log

urls =
    Home page


[config]
max_attempts = 2
base_path = mysite


[Home page]
path = ${config:base_path}/
max_attempts = ${config:max_attempts}
check_exists =
    Welcome
check_not_exists =
    p0wned by
follow_links = True
ignore_middle =
    @@
    ++theme++
    #
    ?
ignore_end =
    .css
    .js
    .png
    .jpg
    .jpeg
    .gif
    .xml
    RSS
    .icoOptionsGlobal [warmup]enableTrueorFalseIfFalse, the script will do nothing when invoked.sleepintegerThe number of seconds the script waits between url retrievals.
Defaults to2.base_urla valid URL (don’t forget the protocol!)The base URL to check
(all paths in the various URL sections are relative to this URL).log_filea filesystem pathThe file where the logs will be written.urlsa list of sections (separated by newline)The URLs that we want to check.
Each URL must have its own section in the configuration file (see below)
and we reference these sections here (do not put real URLs here!).
It also set an order for the checks (which are executed sequentially).URL sectionmax_attemptsintegerThe maximum number of attempts to check the url.
Defaults to2paththe path to checkThe path will be added to thebase_urlparameter in order to retrieve
the page urlcheck_existslist of stringsA list of strings that must be present in the pagecheck_not_existslist of stringsA list of strings that must not be present in the pagefollow_linksTrueorFalseIfTruethe script will follow the links in the page and will
perform the same checks for each link.ignore_middlelist of stringsIffollow_linksisTrue, the links containing one of these strings
will be ignoredignore_endlist of stringsIffollow_linksisTrue, the links ending with one of these strings
will be ignoredHealth checkIn order not to mark backend healthy too early by the load-balancer, before proper
warmup, this package defines a browser view called@@health.checkwhich can be
used within your load-balancer probe mechanism. See bellow a Varnish configuration
example:backend instance_1 {
    .host = "localhost";
    .port = "8081";
    .probe = {
         .url = "/health.check";
         .interval = 5s;
         .timeout = 1s;
         .window = 5;
         .threshold = 3;
     }
}This way Varnish will mark the Zope instance backend healthy when
ZODB cache-size is bigger thanWARMUP_HEALTH_THRESHOLD. If you do not define
theWARMUP_HEALTH_THRESHOLDenvironment variable, the Zope instance backend
will be marked healthy as soon as Zope will be able to handle requests.CreditsChangelog1.2 (2016-09-08)Check for write permissions within logfile and fallback
to a temporary file if can’t write instead of sys.exit
[avoinea]Add @@health.check browser view to be used with load-balancer
health-check in order not to mark backend healthy too early
before proper warmup.
[avoinea]Avoid zombie processes. [jone]Add zcml:condition for Plone 3 compatibility
[gborelli]1.1 (2014-07-18)Python 2.4 support
[gborelli]1.0 (2014-04-06)First release