diff options
author | Jeremy Kerr <jk@ozlabs.org> | 2015-05-28 13:39:05 +0800 |
---|---|---|
committer | Jeremy Kerr <jk@ozlabs.org> | 2015-05-28 13:42:11 +0800 |
commit | f7aeab077874d33fc99354661bfeedf508c292b3 (patch) | |
tree | 729ba784609e430f7b1a679b9b532ecac9732551 | |
parent | 8bd43901bccb34f545a1a686b44339ccdb5f44c7 (diff) | |
download | patchwork-f7aeab077874d33fc99354661bfeedf508c292b3.tar.bz2 patchwork-f7aeab077874d33fc99354661bfeedf508c292b3.tar.xz |
cron: Move patchwork-cron script to a management command
Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
-rw-r--r-- | docs/INSTALL | 4 | ||||
-rw-r--r-- | docs/NEWS | 7 | ||||
-rwxr-xr-x | patchwork/bin/patchwork-cron.py | 15 | ||||
-rwxr-xr-x | patchwork/management/commands/cron.py | 20 |
4 files changed, 28 insertions, 18 deletions
diff --git a/docs/INSTALL b/docs/INSTALL index 9630ad7..611fbb4 100644 --- a/docs/INSTALL +++ b/docs/INSTALL @@ -255,9 +255,7 @@ in brackets): Something like this in your crontab should work: # m h dom mon dow command - PYTHONPATH=. - DJANGO_SETTINGS_MODULE=patchwork.settings.production - */10 * * * * cd patchwork; python patchwork/bin/patchwork-cron.py + */10 * * * * cd patchwork; ./manage.py cron - the frequency should be the same as the NOTIFICATION_DELAY_MINUTES @@ -1,3 +1,10 @@ +== Cron script changes == + +The patchwork cron script has been moved to a manage.py command. Instead +of running patchwork-cron.py, run: + + ./manage.py cron + == Upgrading to 3b8a61c == Recent commits have changed a few admin-visible components of patchwork, so diff --git a/patchwork/bin/patchwork-cron.py b/patchwork/bin/patchwork-cron.py deleted file mode 100755 index 148e97c..0000000 --- a/patchwork/bin/patchwork-cron.py +++ /dev/null @@ -1,15 +0,0 @@ -#!/usr/bin/env python - -import sys -from patchwork.utils import send_notifications, do_expiry - -def main(args): - errors = send_notifications() - for (recipient, error) in errors: - print "Failed sending to %s: %s" % (recipient.email, ex) - - do_expiry() - -if __name__ == '__main__': - sys.exit(main(sys.argv)) - diff --git a/patchwork/management/commands/cron.py b/patchwork/management/commands/cron.py new file mode 100755 index 0000000..6217e75 --- /dev/null +++ b/patchwork/management/commands/cron.py @@ -0,0 +1,20 @@ +#!/usr/bin/env python + +from django.core.management.base import BaseCommand, CommandError +from patchwork.utils import send_notifications, do_expiry + +class Command(BaseCommand): + help = ('Run periodic patchwork functions: send notifications and ' + 'expire unused users') + + def handle(self, *args, **kwargs): + errors = send_notifications() + for (recipient, error) in errors: + self.stderr.write("Failed sending to %s: %s" % + (recipient.email, ex)) + + do_expiry() + +if __name__ == '__main__': + sys.exit(main(sys.argv)) + |