Skip to content

Commit

Permalink
cron: Move patchwork-cron script to a management command
Browse files Browse the repository at this point in the history
Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
  • Loading branch information
jk-ozlabs committed May 28, 2015
1 parent 8bd4390 commit f7aeab0
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 18 deletions.
4 changes: 1 addition & 3 deletions docs/INSTALL
Expand Up @@ -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
Expand Down
7 changes: 7 additions & 0 deletions docs/NEWS
@@ -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
Expand Down
15 changes: 0 additions & 15 deletions patchwork/bin/patchwork-cron.py

This file was deleted.

20 changes: 20 additions & 0 deletions 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))

0 comments on commit f7aeab0

Please sign in to comment.