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 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:" print "\n".join(locks) if (not workers_online) or (pending_tasks > 4000) or locks: return 1 print "Note: To view pending tasks, use bench dump-queue-status" return True
def doctor(site=None): """ Prints diagnostic information for the scheduler """ with frappe.init_site(site): workers_online = check_number_of_workers() jobs_per_queue, job_count = get_jobs_by_queue(site) print "-----Checking scheduler status-----" if site: sites = [site] else: sites = frappe.utils.get_sites() for s in sites: frappe.init(s) frappe.connect() if is_scheduler_disabled(): print "Scheduler disabled for", s frappe.destroy() # TODO improve this print "Workers online:", workers_online print "-----{0} Jobs-----".format(site) for queue in get_queue_list(): if jobs_per_queue[queue]: print "Queue:", queue print "Number of Jobs: ", job_count[queue] print "Methods:" for method, count in jobs_per_queue[queue].iteritems(): print "{0} : {1}".format(method, count) print "------------" return True
def doctor(site=None): """ Prints diagnostic information for the scheduler """ with frappe.init_site(site): workers_online = check_number_of_workers() jobs_per_queue, job_count = get_jobs_by_queue(site) print("-----Checking scheduler status-----") if site: sites = [site] else: sites = frappe.utils.get_sites() for s in sites: frappe.init(s) frappe.connect() if is_scheduler_disabled(): print("Scheduler disabled for", s) if frappe.local.conf.maintenance_mode: print("Maintenance mode on for", s) if frappe.local.conf.pause_scheduler: print("Scheduler paused for", s) if is_scheduler_inactive(): print("Scheduler inactive for", s) frappe.destroy() # TODO improve this print("Workers online:", workers_online) print("-----{0} Jobs-----".format(site)) for queue in get_queue_list(): if jobs_per_queue[queue]: print("Queue:", queue) print("Number of Jobs: ", job_count[queue]) print("Methods:") for method, count in jobs_per_queue[queue].items(): print("{0} : {1}".format(method, count)) print("------------") return True