def run(self): # pylint: disable=E0202 from flask import current_app from celery.bin import beat from async.celery_helpers import CeleryFactory celery = CeleryFactory(current_app).celery beat = beat.beat(app=celery) beat.run(loglevel=logging.INFO, schedule="async/celerybeat-schedule")
def nres_start_stacking_scheduler(): logger.info('Entered entrypoint to celery beat scheduling') runtime_context = parse_args(banzai_nres.settings) for site, entry in runtime_context.SCHEDULE_STACKING_CRON_ENTRIES.items(): app.add_periodic_task(crontab(minute=entry['minute'], hour=entry['hour']), schedule_calibration_stacking.s(site=site, runtime_context=vars(runtime_context))) beat = celery.bin.beat.beat(app=app) logger.info('Starting celery beat') beat.run()
def start_stacking_scheduler(): logger.info('Entered entrypoint to celery beat scheduling') runtime_context = parse_directory_args() beat_schedule = { site + 'beat': { 'task': 'banzai.celery.schedule_calibration_stacking', 'schedule': crontab(minute=entry['minute'], hour=entry['hour']), 'args': (site, vars(runtime_context)) } for site, entry in runtime_context.SCHEDULE_STACKING_CRON_ENTRIES.items() } app.conf.update(beat_schedule=beat_schedule) beat = celery.bin.beat.beat(app=app) logger.info('Starting celery beat') beat.run()
def handle(self, *args, **options): beat.run(*args, **options)
task_modules = ['proj.test_tasks'] app = Celery("CeleryTest", include=task_modules) app.config_from_object('celeryconfig') # Alternatively, tasks can be automatically discovered. # By default, a module containing tasks should be named as tasks.py # app.autodiscover_tasks(['proj']) def setup_logging(**kwargs): app.log.redirect_stdouts_to_logger(__log) signals.setup_logging.connect(setup_logging) __log.info("initialization of celery app done") if __name__ == '__main__': # debug Celery worker # argv = [ # 'worker', # '--loglevel=DEBUG', # '-B' # ] # app.worker_main(argv) # debug Celery beat beat = beat.beat(app=app) options = {'scheduler': 'proj.custom_scheduler.CustomScheduler'} beat.run(**options)
#/usr/bin/env python from celery import current_app from celery.bin import beat from run import app from settings import * application = current_app._get_current_object() application.config_from_object('settings') beat = beat.beat(app=application) options = { 'broker': CELERY_BROKER_URL, 'loglevel': 'INFO', 'traceback': True, } beat.run(**options)