celerybeat.py 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. #!/usr/bin/env python
  2. """celerybeat
  3. .. program:: celerybeat
  4. .. cmdoption:: -s, --schedule
  5. Path to the schedule database. Defaults to ``celerybeat-schedule``.
  6. The extension ".db" will be appended to the filename.
  7. .. cmdoption:: -S, --scheduler
  8. Scheduler class to use. Default is celery.beat.PersistentScheduler
  9. .. cmdoption:: -f, --logfile
  10. Path to log file. If no logfile is specified, ``stderr`` is used.
  11. .. cmdoption:: -l, --loglevel
  12. Logging level, choose between ``DEBUG``, ``INFO``, ``WARNING``,
  13. ``ERROR``, ``CRITICAL``, or ``FATAL``.
  14. """
  15. from celery.bin.base import Command, Option
  16. class BeatCommand(Command):
  17. def run(self, *args, **kwargs):
  18. kwargs.pop("app", None)
  19. return self.app.Beat(**kwargs).run()
  20. def get_options(self):
  21. conf = self.app.conf
  22. return (
  23. Option('-s', '--schedule',
  24. default=conf.CELERYBEAT_SCHEDULE_FILENAME,
  25. action="store", dest="schedule",
  26. help="Path to the schedule database. The extension "
  27. "'.db' will be appended to the filename. Default: %s" % (
  28. conf.CELERYBEAT_SCHEDULE_FILENAME, )),
  29. Option('--max-interval',
  30. default=3600.0, type="float", dest="max_interval",
  31. help="Max. seconds to sleep between schedule iterations."),
  32. Option('-S', '--scheduler',
  33. default=None,
  34. action="store", dest="scheduler_cls",
  35. help="Scheduler class. Default is "
  36. "celery.beat.PersistentScheduler"),
  37. Option('-f', '--logfile', default=conf.CELERYBEAT_LOG_FILE,
  38. action="store", dest="logfile",
  39. help="Path to log file."),
  40. Option('-l', '--loglevel',
  41. default=conf.CELERYBEAT_LOG_LEVEL,
  42. action="store", dest="loglevel",
  43. help="Loglevel. One of DEBUG/INFO/WARNING/ERROR/CRITICAL."),
  44. )
  45. def main():
  46. beat = BeatCommand()
  47. beat.execute_from_commandline()
  48. if __name__ == "__main__": # pragma: no cover
  49. main()