1
0

runserver.py 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  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. parser = argparse.ArgumentParser(
  9. description='Run the Pagure app')
  10. parser.add_argument(
  11. '--config', '-c', dest='config',
  12. help='Configuration file to use for pagure.')
  13. parser.add_argument(
  14. '--debug', dest='debug', action='store_true',
  15. default=False,
  16. help='Expand the level of data returned.')
  17. parser.add_argument(
  18. '--profile', dest='profile', action='store_true',
  19. default=False,
  20. help='Profile Pagure.')
  21. parser.add_argument(
  22. '--perf-verbose', dest='perfverbose', action='store_true',
  23. default=False,
  24. help='Enable per-request printing of performance statistics.')
  25. parser.add_argument(
  26. '--port', '-p', default=5000,
  27. help='Port for the Pagure to run on.')
  28. parser.add_argument(
  29. '--no-debug', action='store_true',
  30. help='Disable debugging')
  31. parser.add_argument(
  32. '--host', default="127.0.0.1",
  33. help='Hostname to listen on. When set to 0.0.0.0 the server is available '
  34. 'externally. Defaults to 127.0.0.1 making the it only visible on localhost')
  35. args = parser.parse_args()
  36. if args.config:
  37. config = args.config
  38. if not config.startswith('/'):
  39. here = os.path.join(os.path.dirname(os.path.abspath(__file__)))
  40. config = os.path.join(here, config)
  41. os.environ['PAGURE_CONFIG'] = config
  42. if args.perfverbose:
  43. os.environ['PAGURE_PERFREPO'] = 'true'
  44. os.environ['PAGURE_PERFREPO_VERBOSE'] = 'true'
  45. from pagure import APP
  46. if args.profile:
  47. from werkzeug.contrib.profiler import ProfilerMiddleware
  48. APP.config['PROFILE'] = True
  49. APP.wsgi_app = ProfilerMiddleware(APP.wsgi_app, restrictions=[30])
  50. APP.debug = not args.no_debug
  51. APP.run(host=args.host, port=int(args.port))