1
0

rundocserver.py 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. #!/usr/bin/env python
  2. from __future__ import unicode_literals, absolute_import
  3. # These two lines are needed to run on EL6
  4. __requires__ = ['jinja2 >= 2.4']
  5. import pkg_resources
  6. import argparse
  7. import sys
  8. import os
  9. parser = argparse.ArgumentParser(
  10. description='Run the Pagure doc server')
  11. parser.add_argument(
  12. '--config', '-c', dest='config',
  13. help='Configuration file to use for the pagure doc server.')
  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. '--profile', dest='profile', action='store_true',
  20. default=False,
  21. help='Profile the doc server.')
  22. parser.add_argument(
  23. '--port', '-p', default=5001,
  24. help='Port for the Pagure doc server to run on.')
  25. parser.add_argument(
  26. '--host', default="127.0.0.1",
  27. help='Hostname to listen on. When set to 0.0.0.0 the server is '
  28. 'available externally. Defaults to 127.0.0.1 making the it only '
  29. 'visible on localhost')
  30. args = parser.parse_args()
  31. if args.config:
  32. config = args.config
  33. if not config.startswith('/'):
  34. here = os.path.join(os.path.dirname(os.path.abspath(__file__)))
  35. config = os.path.join(here, config)
  36. os.environ['PAGURE_CONFIG'] = config
  37. from pagure.docs_server import APP
  38. if args.profile:
  39. from werkzeug.contrib.profiler import ProfilerMiddleware
  40. APP.config['PROFILE'] = True
  41. APP.wsgi_app = ProfilerMiddleware(APP.wsgi_app, restrictions=[30])
  42. APP.debug = True
  43. APP.run(host=args.host, port=int(args.port))