def run_celerybeat(self): from main.celery import app from celery.bin import beat beat.beat(app=app).run(loglevel='INFO', logfile=join(settings.ROOT_DIR, 'logs', 'celerybeat.log'))
def run_beat(): """ celery beat """ with current_app.app_context() as context: beat(context.app.extensions['celery'].celery).execute_from_commandline( argv=['beat', '--loglevel=INFO', '--schedule', path.dirname(__file__) + '/beat.db'])
def run_celerybeat(self): from main.celery import app from celery.bin import beat beat.beat(app=app).run(loglevel="INFO", logfile=join(settings.ROOT_DIR, "logs", "celerybeat.log"))
def run_beat(): """ celery beat """ beat(ccelery).execute_from_commandline(argv=[ 'beat', '--loglevel=INFO', '--schedule', os.path.dirname(__file__) + '/beat.db' ])
def celery_beater(): from celery.bin.beat import beat from hcloud.libs.celery.celery import celery as celery_app from hcloud.config import CELERY_LOGLEVEL, CELERY_LOG_FILE celery_beater = beat(app=celery_app) celery_beater.run(loglevel=CELERY_LOGLEVEL, logfile=CELERY_LOG_FILE, hostname='%%h')
def beat(args): """Runs the Celery beat.""" from celery.bin.beat import beat return beat(app=current_app.celery).run_from_argv('je moeder', args, command='beat')
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 run_celerybeat(): """Function that starts the scheduled tasks in celery using celery.beat""" runner = beat.beat(app=celery) config = { "loglevel": "INFO", "schedule": os.path.join(celery.conf["DATA_DIR"], "celerybeat-schedule"), } runner.run(**config)
def beat(logfile, concurrency): """Starts the celery beat.""" config = deepcopy(current_config.CELERY_BEAT_CONFIG) if logfile: config.update(logfile=logfile) if concurrency: config.update(concurrency=concurrency) application = current_celery_app._get_current_object() application.conf.update(CELERYBEAT_SCHEDULE=CELERYBEAT_SCHEDULE) my_beat = beat_app.beat(app=application) logger.info("beat environment : {}".format(config_name)) my_beat.run(**config)
def runtask(name=None): """Run task server""" from celery.bin.worker import worker from celery.bin.beat import beat log_level = app.config.get('CELERY_LOG_LEVEL') if name == 'celery': worker = worker(app=app.celery) worker.run(loglevel=log_level) elif name == 'beat': beat = beat(app=app.celery) beat.run(loglevel=log_level) elif name == 'all': worker = worker(app=app.celery) worker.run(loglevel=log_level, beat=True) else: print("Usage: python manager.py runtask -n [celery | beat | all]")
def run_beat(self): if self.beat_started: return application = current_app._get_current_object() celery_beat = beat.beat(app=application) options = { "broker": self.config["CELERY_BROKER_URL"], "loglevel": "INFO", "traceback": True, "beat": True, "schedule": os.path.join(str(tempfile.mkdtemp()), "celery-beat-schedule"), } celery_beat.run(**options)
def beat(): cbeat = celery_beat.beat(app=celery_app) cbeat.run()
def test_parse_options(self): cmd = beat_bin.beat() cmd.app = self.app options, args = cmd.parse_options('celery beat', ['-s', 'foo']) assert options['schedule'] == 'foo'
def test_detach(self): cmd = beat_bin.beat() cmd.app = self.app cmd.run(detach=True) self.detached.assert_called()
def run_beat(application): c_beat=beat.beat(app=application) c_beat.run(loglevel='DEBUG')
def run_beat(application): c_beat = beat.beat(app=application) c_beat.run(loglevel='INFO')
""" Start the celery clock service from the Django management command. """ from __future__ import absolute_import, unicode_literals from celery.bin import beat from djcelery.app import app from djcelery.management.base import CeleryCommand beat = beat.beat(app=app) class Command(CeleryCommand): """Run the celery periodic task scheduler.""" options = (CeleryCommand.options + beat.get_options() + beat.preload_options) help = 'Old alias to the "celery beat" command.' requires_model_validation = False def handle(self, *args, **options): beat.run(*args, **options)
def test_parse_options(self): cmd = beat_bin.beat() cmd.app = self.app options, args = cmd.parse_options('celery beat', ['-s', 'foo']) self.assertEqual(options.schedule, 'foo')
def main(): setup_basic_logger() aggregator.config_from_object(app.config.scheduler) maybe_patch_concurrency() beat(aggregator).execute_from_commandline()
def test_detach(self): cmd = beat_bin.beat() cmd.app = app_or_default() cmd.run(detach=True) self.assertTrue(MockDaemonContext.opened) self.assertTrue(MockDaemonContext.closed)
def test_parse_options(self): cmd = beat_bin.beat() cmd.app = app_or_default() options, args = cmd.parse_options('celery beat', ['-s', 'foo']) self.assertEqual(options.schedule, 'foo')
def test_detach(self): cmd = beat_bin.beat() cmd.app = self.app cmd.run(detach=True) self.assertTrue(MockDaemonContext.opened) self.assertTrue(MockDaemonContext.closed)
#/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)
""" Start the celery clock service from the Django management command. """ from __future__ import absolute_import, unicode_literals from optparse import make_option as Option from celery.bin import beat from blueapps.contrib.bk_commands.management.app import app from blueapps.contrib.bk_commands.management.base import CeleryCommand beat = beat.beat(app=app) class Command(CeleryCommand): """Run the celery periodic task scheduler.""" help = 'Old alias to the "celery beat" command.' options = ( Option('-A', '--app', default=None), Option('--broker', default=None), Option('--loader', default=None), Option('--config', default=None), Option('--workdir', default=None, dest='working_directory'), Option('--result-backend', default=None), Option('--no-color', '-C', action='store_true', default=None), Option('--quiet', '-q', action='store_true'), ) if beat.get_options() is not None: