Skip to content

Commit a879986

Browse files
committed
fix(doctor): Show status of scheduler in bench doctor
1 parent e6e49e4 commit a879986

3 files changed

Lines changed: 29 additions & 9 deletions

File tree

frappe/commands/scheduler.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,9 +115,12 @@ def set_maintenance_mode(context, state, site=None):
115115

116116
@click.command('doctor') #Passing context always gets a site and if there is no use site it breaks
117117
@click.option('--site', help='site name')
118-
def doctor(site=None):
118+
@pass_context
119+
def doctor(context, site=None):
119120
"Get diagnostic info about background workers"
120121
from frappe.utils.doctor import doctor as _doctor
122+
if not site:
123+
site = get_site(context)
121124
return _doctor(site=site)
122125

123126
@click.command('show-pending-jobs')

frappe/utils/doctor.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
from collections import defaultdict
44
from rq import Worker, Connection
55
from frappe.utils.background_jobs import get_redis_conn, get_queue, get_queue_list
6-
from frappe.utils.scheduler import is_scheduler_disabled
6+
from frappe.utils.scheduler import is_scheduler_disabled, is_scheduler_inactive
77
from six import iteritems
88

99

@@ -107,8 +107,19 @@ def doctor(site=None):
107107
for s in sites:
108108
frappe.init(s)
109109
frappe.connect()
110+
110111
if is_scheduler_disabled():
111112
print("Scheduler disabled for", s)
113+
114+
if frappe.local.conf.maintenance_mode:
115+
print("Maintenance mode on for", s)
116+
117+
if frappe.local.conf.pause_scheduler:
118+
print("Scheduler paused for", s)
119+
120+
if is_scheduler_inactive():
121+
print("Scheduler inactive for", s)
122+
112123
frappe.destroy()
113124

114125
# TODO improve this

frappe/utils/scheduler.py

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -83,14 +83,8 @@ def log_and_raise():
8383

8484
try:
8585
frappe.init(site=site)
86-
if frappe.local.conf.maintenance_mode:
87-
return
88-
89-
if frappe.local.conf.pause_scheduler:
90-
return
91-
9286
frappe.connect()
93-
if is_scheduler_disabled():
87+
if is_scheduler_inactive():
9488
return
9589

9690
enqueue_events(site=site, queued_jobs=queued_jobs)
@@ -230,6 +224,18 @@ def get_enabled_scheduler_events():
230224
return ["all", "hourly", "hourly_long", "daily", "daily_long",
231225
"weekly", "weekly_long", "monthly", "monthly_long", "cron"]
232226

227+
def is_scheduler_inactive():
228+
if frappe.local.conf.maintenance_mode:
229+
return True
230+
231+
if frappe.local.conf.pause_scheduler:
232+
return True
233+
234+
if is_scheduler_disabled():
235+
return True
236+
237+
return False
238+
233239
def is_scheduler_disabled():
234240
if frappe.conf.disable_scheduler:
235241
return True

0 commit comments

Comments
 (0)