runserver.py 1.43 KB
Newer Older
Pierre-Yves Chibon's avatar
Pierre-Yves Chibon committed
1
#!/usr/bin/env python2
2

Pierre-Yves Chibon's avatar
Pierre-Yves Chibon committed
3
# These two lines are needed to run on EL6
4
__requires__ = ['SQLAlchemy >= 0.8', 'jinja2 >= 2.4']
5 6
import pkg_resources

7
import argparse
8
import sys
9
import os
10 11


12
parser = argparse.ArgumentParser(
13
    description='Run the Pagure app')
14 15
parser.add_argument(
    '--config', '-c', dest='config',
16
    help='Configuration file to use for pagure.')
17 18 19 20 21 22 23
parser.add_argument(
    '--debug', dest='debug', action='store_true',
    default=False,
    help='Expand the level of data returned.')
parser.add_argument(
    '--profile', dest='profile', action='store_true',
    default=False,
24
    help='Profile Pagure.')
25 26
parser.add_argument(
    '--port', '-p', default=5000,
27 28 29 30
    help='Port for the Pagure to run on.')
parser.add_argument(
    '--host', default="127.0.0.1",
    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')
31 32 33 34

args = parser.parse_args()

if args.config:
35 36 37 38 39
    config = args.config
    if not config.startswith('/'):
        here = os.path.join(os.path.dirname(os.path.abspath(__file__)))
        config = os.path.join(here, config)
    os.environ['PAGURE_CONFIG'] = config
40

41 42 43 44 45 46 47
from pagure import APP

if args.profile:
    from werkzeug.contrib.profiler import ProfilerMiddleware
    APP.config['PROFILE'] = True
    APP.wsgi_app = ProfilerMiddleware(APP.wsgi_app, restrictions=[30])

48
APP.debug = True
49
APP.run(host=args.host, port=int(args.port))