runworker.py 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  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(
  8. description='Run the Pagure worker')
  9. parser.add_argument(
  10. '--config', '-c', dest='config',
  11. help='Configuration file to use for pagure.')
  12. parser.add_argument(
  13. '--debug', dest='debug', action='store_true',
  14. default=False,
  15. help='Expand the level of data returned.')
  16. parser.add_argument(
  17. '--noinfo', dest='noinfo', action='store_true',
  18. default=False,
  19. help='Reduce the log level.')
  20. args = parser.parse_args()
  21. env = {}
  22. if args.config:
  23. config = args.config
  24. if not config.startswith('/'):
  25. here = os.path.join(os.path.dirname(os.path.abspath(__file__)))
  26. config = os.path.join(here, config)
  27. env['PAGURE_CONFIG'] = config
  28. cmd = [
  29. sys.executable, '-m', 'celery', 'worker', '-A', 'pagure.lib.tasks'
  30. ]
  31. if args.debug:
  32. cmd.append('--loglevel=debug')
  33. elif args.noinfo:
  34. pass
  35. else:
  36. cmd.append('--loglevel=info')
  37. subp = subprocess.Popen(cmd, env=env or None)
  38. subp.wait()