mirror of
https://github.com/jumpserver/jumpserver.git
synced 2025-09-01 07:27:35 +00:00
feat(celery): 添加celery的health check接口
This commit is contained in:
20
apps/ops/management/commands/check_celery.py
Normal file
20
apps/ops/management/commands/check_celery.py
Normal file
@@ -0,0 +1,20 @@
|
||||
from django.core.management.base import BaseCommand, CommandError
|
||||
|
||||
|
||||
class Command(BaseCommand):
|
||||
help = 'Ops manage commands'
|
||||
|
||||
def add_arguments(self, parser):
|
||||
parser.add_argument('check_celery', nargs='?', help='Check celery health')
|
||||
|
||||
def handle(self, *args, **options):
|
||||
from ops.celery.utils import get_celery_status, get_beat_status
|
||||
|
||||
ok = get_celery_status()
|
||||
if not ok:
|
||||
raise CommandError('Celery worker unhealthy')
|
||||
|
||||
ok = get_beat_status()
|
||||
if not ok:
|
||||
raise CommandError('Beat unhealthy')
|
||||
|
Reference in New Issue
Block a user