File: README.md

package info (click to toggle)
django-housekeeping 1.2-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye, sid
  • size: 172 kB
  • sloc: python: 673; makefile: 3
file content (76 lines) | stat: -rw-r--r-- 1,975 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
# django-housekeeping

Pluggable housekeeping framework for Django sites.

django\_housekeeping provides a management command that finds and run tasks
defined by your Django apps.

Tasks can declare dependencies on each other, run in multiple stages and
provide infrastructure that other tasks can use.

## Example

### Code

    # myapp/housekeeping.py:
    import django_housekeeping as hk
    import logging

    # Logging will be properly configured and can be used at will
    log = logging.getLogger(__name__)


    # Order of execution of the housekeeping stages defined in this module
    STAGES = ["backup", "main"]

    class BackupDB(hk.Task):
        """
        Backup of the whole database
        """
        def run_backup(self, stage):
            # ...backup the database...

    class DailyAggregates(hk.Task):
        """
        Compute daily aggregates
        """
        def run_main(self, stage):
            # ...compute...

    class MonthlyAggregates(hk.Task):
        """
        Compute monthly aggregates
        """
        DEPENDS = [DailyAggregates]

        def run_main(self, stage):
            # ...compute monthly averages from daily averages...

### Execution

django\_housekeeping adds a `housekeeping` management command that runs all
tasks. You can schedule `./manage.py housekeeping` to run once a day to
automate the site maintenance.

To run the housekeeping tasks, just run:

    $ ./manage.py housekeeping

To see the order in which the tasks would be run, use:

    $ ./manage.py housekeeping --list

You can use `--logfile` to write a verbose log file, or run only some tasks
using `--include` and `--exclude`. See `./manage.py housekeeping --help` for
details.


## Configuration

There is currently only one configuration key for `settings.py`:
`HOUSEKEEPING_ROOT`. Set it to a string with a directory pathname, and it is
the same as if `--outdir=OUTDIR` is set.

Example:

	HOUSEKEEPING_ROOT = "/srv/mysite/housekeeping/"