1
0

runworker.py 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. #!/usr/bin/env python
  2. from __future__ import unicode_literals, absolute_import
  3. import argparse
  4. import sys
  5. import os
  6. import subprocess
  7. parser = argparse.ArgumentParser(description="Run the Pagure worker")
  8. parser.add_argument(
  9. "--config",
  10. "-c",
  11. dest="config",
  12. help="Configuration file to use for pagure.",
  13. )
  14. parser.add_argument(
  15. "--debug",
  16. dest="debug",
  17. action="store_true",
  18. default=False,
  19. help="Expand the level of data returned.",
  20. )
  21. parser.add_argument(
  22. "--noinfo",
  23. dest="noinfo",
  24. action="store_true",
  25. default=False,
  26. help="Reduce the log level.",
  27. )
  28. args = parser.parse_args()
  29. env = {}
  30. if args.config:
  31. config = args.config
  32. if not config.startswith("/"):
  33. here = os.path.join(os.path.dirname(os.path.abspath(__file__)))
  34. config = os.path.join(here, config)
  35. env["PAGURE_CONFIG"] = config
  36. cmd = [sys.executable, "-m", "celery", "worker", "-A", "pagure.lib.tasks"]
  37. if args.debug:
  38. cmd.append("--loglevel=debug")
  39. elif args.noinfo:
  40. pass
  41. else:
  42. cmd.append("--loglevel=info")
  43. subp = subprocess.Popen(cmd, env=env or None)
  44. subp.wait()