From f62f03acfc8d0b7e7389b13afc303a682ca740f9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20P=C3=A9ters?= Date: Wed, 5 Apr 2017 16:26:01 +0200 Subject: [PATCH] general: add possibility to skip all cron jobs (#15470) This is useful for load balancing as jobs should only be run on one host. --- hobo/multitenant/management/commands/tenant_command.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/hobo/multitenant/management/commands/tenant_command.py b/hobo/multitenant/management/commands/tenant_command.py index d54fc26..8580461 100644 --- a/hobo/multitenant/management/commands/tenant_command.py +++ b/hobo/multitenant/management/commands/tenant_command.py @@ -3,7 +3,10 @@ # Email: carneiro.be@gmail.com # License: MIT license # Home-page: http://github.com/bcarneiro/django-tenant-schemas + import argparse + +from django.conf import settings from django.core.management.base import BaseCommand, CommandError from django.core.management import call_command, get_commands, load_command_class from django.db import connection @@ -39,8 +42,12 @@ class Command(InteractiveTenantOption, BaseCommand): args_parser.add_argument("--all-tenants", help="apply command to all tenants", action='store_true') args_parser.add_argument("-d", "--domain", dest="domain_name", help="specify tenant domain name") + args_parser.add_argument('--force-job', dest='force_job', action='store_true') args_namespace, args = args_parser.parse_known_args(argv) + if not args_namespace.force_job and getattr(settings, 'DISABLE_CRON_JOBS', False): + return + if args_namespace.all_tenants: for tenant in TenantMiddleware.get_tenants(): connection.set_tenant(tenant) -- 2.11.0