runserver.py 1.4 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. 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. '--port', '-p', default=5000,
  23. help='Port for the Pagure 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 available externally. Defaults to 127.0.0.1 making the it only visable on localhost')
  27. args = parser.parse_args()
  28. if args.config:
  29. config = args.config
  30. if not config.startswith('/'):
  31. here = os.path.join(os.path.dirname(os.path.abspath(__file__)))
  32. config = os.path.join(here, config)
  33. os.environ['PAGURE_CONFIG'] = config
  34. from pagure import APP
  35. if args.profile:
  36. from werkzeug.contrib.profiler import ProfilerMiddleware
  37. APP.config['PROFILE'] = True
  38. APP.wsgi_app = ProfilerMiddleware(APP.wsgi_app, restrictions=[30])
  39. APP.debug = True
  40. APP.run(host=args.host, port=int(args.port))