Blame rundocserver.py

Neal Gompa 55fa35
#!/usr/bin/env python
Pierre-Yves Chibon f8556c
Pierre-Yves Chibon 67d1cc
from __future__ import unicode_literals, absolute_import
Aurélien Bompard dcf6f6
Pierre-Yves Chibon f8556c
# These two lines are needed to run on EL6
Pierre-Yves Chibon d9e6bc
__requires__ = ['jinja2 >= 2.4']
Pierre-Yves Chibon f8556c
import pkg_resources
Pierre-Yves Chibon f8556c
Pierre-Yves Chibon 5274cc
import argparse
Pierre-Yves Chibon f8556c
import sys
Pierre-Yves Chibon 5274cc
import os
Pierre-Yves Chibon 5274cc
Pierre-Yves Chibon 5274cc
Pierre-Yves Chibon 5274cc
parser = argparse.ArgumentParser(
Pierre-Yves Chibon 5274cc
    description='Run the Pagure doc server')
Pierre-Yves Chibon 5274cc
parser.add_argument(
Pierre-Yves Chibon 5274cc
    '--config', '-c', dest='config',
Pierre-Yves Chibon 5274cc
    help='Configuration file to use for the pagure doc server.')
Pierre-Yves Chibon 5274cc
parser.add_argument(
Pierre-Yves Chibon 5274cc
    '--debug', dest='debug', action='store_true',
Pierre-Yves Chibon 5274cc
    default=False,
Pierre-Yves Chibon 5274cc
    help='Expand the level of data returned.')
Pierre-Yves Chibon 5274cc
parser.add_argument(
Pierre-Yves Chibon 5274cc
    '--profile', dest='profile', action='store_true',
Pierre-Yves Chibon 5274cc
    default=False,
Pierre-Yves Chibon 5274cc
    help='Profile the doc server.')
Pierre-Yves Chibon 5274cc
parser.add_argument(
Pierre-Yves Chibon 5274cc
    '--port', '-p', default=5001,
Pierre-Yves Chibon 5274cc
    help='Port for the Pagure doc server to run on.')
Pierre-Yves Chibon 5274cc
parser.add_argument(
Pierre-Yves Chibon 5274cc
    '--host', default="127.0.0.1",
Pierre-Yves Chibon 5274cc
    help='Hostname to listen on. When set to 0.0.0.0 the server is '
Pierre-Yves Chibon 5274cc
    'available externally. Defaults to 127.0.0.1 making the it only '
Pierre-Yves Chibon fe3bb6
    'visible on localhost')
Pierre-Yves Chibon 5274cc
Pierre-Yves Chibon 5274cc
args = parser.parse_args()
Pierre-Yves Chibon 5274cc
Pierre-Yves Chibon 5274cc
if args.config:
Pierre-Yves Chibon 5274cc
    config = args.config
Pierre-Yves Chibon 5274cc
    if not config.startswith('/'):
Pierre-Yves Chibon 5274cc
        here = os.path.join(os.path.dirname(os.path.abspath(__file__)))
Pierre-Yves Chibon 5274cc
        config = os.path.join(here, config)
Pierre-Yves Chibon 5274cc
    os.environ['PAGURE_CONFIG'] = config
Pierre-Yves Chibon f8556c
Pierre-Yves Chibon f8556c
from pagure.docs_server import APP
Pierre-Yves Chibon f8556c
Pierre-Yves Chibon 5274cc
if args.profile:
Pierre-Yves Chibon 5274cc
    from werkzeug.contrib.profiler import ProfilerMiddleware
Pierre-Yves Chibon f8556c
    APP.config['PROFILE'] = True
Pierre-Yves Chibon f8556c
    APP.wsgi_app = ProfilerMiddleware(APP.wsgi_app, restrictions=[30])
Pierre-Yves Chibon f8556c
Pierre-Yves Chibon 5274cc
APP.debug = True
Pierre-Yves Chibon 5274cc
APP.run(host=args.host, port=int(args.port))