runworker.py 1.1 KB

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