1
0

rundocserver.py 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  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 doc server')
  10. parser.add_argument(
  11. '--config', '-c', dest='config',
  12. help='Configuration file to use for the pagure doc server.')
  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 the doc server.')
  21. parser.add_argument(
  22. '--port', '-p', default=5001,
  23. help='Port for the Pagure doc server to run on.')
  24. parser.add_argument(
  25. '--host', default="127.0.0.1",
  26. help='Hostname to listen on. When set to 0.0.0.0 the server is '
  27. 'available externally. Defaults to 127.0.0.1 making the it only '
  28. 'visible on localhost')
  29. args = parser.parse_args()
  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. os.environ['PAGURE_CONFIG'] = config
  36. from pagure.docs_server import APP
  37. if args.profile:
  38. from werkzeug.contrib.profiler import ProfilerMiddleware
  39. APP.config['PROFILE'] = True
  40. APP.wsgi_app = ProfilerMiddleware(APP.wsgi_app, restrictions=[30])
  41. APP.debug = True
  42. APP.run(host=args.host, port=int(args.port))