diff --git a/frappe/__init__.py b/frappe/__init__.py index 8d558220ff..141da8f48b 100644 --- a/frappe/__init__.py +++ b/frappe/__init__.py @@ -173,6 +173,8 @@ def get_site_config(sites_path=None, site_path=None): site_config = os.path.join(site_path, "site_config.json") if os.path.exists(site_config): config.update(get_file_json(site_config)) + elif local.site: + raise IncorrectSitePath, "{0} does not exist".format(site_config) return _dict(config) diff --git a/frappe/commands.py b/frappe/commands.py index 81e3ee8689..1e0551dfe3 100644 --- a/frappe/commands.py +++ b/frappe/commands.py @@ -828,7 +828,6 @@ def request(context, args): def doctor(): "Get diagnostic info about background workers" from frappe.utils.doctor import doctor as _doctor - frappe.init('') return _doctor() @click.command('celery-doctor') diff --git a/frappe/exceptions.py b/frappe/exceptions.py index bdb6eb07a5..0eb4af42e3 100644 --- a/frappe/exceptions.py +++ b/frappe/exceptions.py @@ -59,3 +59,5 @@ class InvalidEmailAddressError(ValidationError): pass class TemplateNotFoundError(ValidationError): pass class UniqueValidationError(ValidationError): pass class AppNotInstalledError(ValidationError): pass +class IncorrectSitePath(ValidationError): pass + diff --git a/frappe/utils/doctor.py b/frappe/utils/doctor.py index a7e5b9ffa6..fd40f414f4 100644 --- a/frappe/utils/doctor.py +++ b/frappe/utils/doctor.py @@ -3,6 +3,7 @@ import json, base64, os import frappe.utils from frappe.celery_app import get_celery from frappe.utils.file_lock import check_lock, LockTimeoutError +from frappe.utils.scheduler import is_scheduler_disabled from collections import Counter from operator import itemgetter @@ -140,9 +141,21 @@ def doctor(): """ Prints diagnostic information for the scheduler """ + print "Inspecting workers and queues..." workers_online = check_if_workers_online() pending_tasks = get_pending_task_count() + + print "Finding locks..." locks = get_timedout_locks() + + print "Checking scheduler status..." + for site in frappe.utils.get_sites(): + frappe.init(site) + frappe.connect() + if not is_scheduler_disabled(): + print "{0:40}: Scheduler disabled via System Settings or site_config.json".format(site) + frappe.destroy() + print "Workers online:", workers_online print "Pending tasks", pending_tasks print "Timed out locks:"