ds

馋奶兔 提交于 2019-12-02 12:21:55
# Copyright 2018-present Lenovo
# Confidential and Proprietary

from django.core.management.base import BaseCommand

__all__ = ['Command']


class Command(BaseCommand):
    help = 'launch celery beat.'

    def add_arguments(self, parser):
        parser.add_argument(
            '--log-level', default='INFO',
            choices=['DEBUG', 'INFO', 'WARNING', 'ERROR', 'CRITICAL', 'FATAL'],
            help='Logging level'
        )
        parser.add_argument(
            '--conf-path', default='/var/run/lico/core',
            help='Store pid file and schedule db'
        )

    def handle(self, *args, **options):
        from antilles.common.main import app

        celery_conf_path = options['conf_path']
        from os import makedirs, path
        if not path.exists(celery_conf_path):
            makedirs(celery_conf_path, mode=0755)

        pid_file = path.join(celery_conf_path, "celerybeat.pid")
        schedule_db = path.join(celery_conf_path, "celerybeat-schedule")

        app.start(
            argv=['celery', 'beat', '-l', options['log_level'],
                  '--pidfile', pid_file, '-s', schedule_db]
        )

  

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!