|
Pierre-Yves Chibon |
f92068 |
#!/usr/bin/env python2
|
|
Pierre-Yves Chibon |
2088eb |
|
|
Pierre-Yves Chibon |
fb4210 |
# These two lines are needed to run on EL6
|
|
Pierre-Yves Chibon |
ee9b42 |
__requires__ = ['SQLAlchemy >= 0.8', 'jinja2 >= 2.4']
|
|
Pierre-Yves Chibon |
2088eb |
import pkg_resources
|
|
Pierre-Yves Chibon |
2088eb |
|
|
Pierre-Yves Chibon |
d04562 |
import argparse
|
|
Pierre-Yves Chibon |
281f75 |
import sys
|
|
Pierre-Yves Chibon |
d04562 |
import os
|
|
Pierre-Yves Chibon |
281f75 |
|
|
Pierre-Yves Chibon |
281f75 |
|
|
Pierre-Yves Chibon |
d04562 |
parser = argparse.ArgumentParser(
|
|
Ryan Lerch |
73a5b2 |
description='Run the Pagure app')
|
|
Pierre-Yves Chibon |
d04562 |
parser.add_argument(
|
|
Pierre-Yves Chibon |
d04562 |
'--config', '-c', dest='config',
|
|
Ryan Lerch |
73a5b2 |
help='Configuration file to use for pagure.')
|
|
Pierre-Yves Chibon |
d04562 |
parser.add_argument(
|
|
Pierre-Yves Chibon |
d04562 |
'--debug', dest='debug', action='store_true',
|
|
Pierre-Yves Chibon |
d04562 |
default=False,
|
|
Pierre-Yves Chibon |
d04562 |
help='Expand the level of data returned.')
|
|
Pierre-Yves Chibon |
d04562 |
parser.add_argument(
|
|
Pierre-Yves Chibon |
d04562 |
'--profile', dest='profile', action='store_true',
|
|
Pierre-Yves Chibon |
d04562 |
default=False,
|
|
Ryan Lerch |
73a5b2 |
help='Profile Pagure.')
|
|
Pierre-Yves Chibon |
d04562 |
parser.add_argument(
|
|
Pierre-Yves Chibon |
d04562 |
'--port', '-p', default=5000,
|
|
Ryan Lerch |
73a5b2 |
help='Port for the Pagure to run on.')
|
|
Ryan Lerch |
73a5b2 |
parser.add_argument(
|
|
Ryan Lerch |
73a5b2 |
'--host', default="127.0.0.1",
|
|
Pierre-Yves Chibon |
fe3bb6 |
help='Hostname to listen on. When set to 0.0.0.0 the server is available '
|
|
Pierre-Yves Chibon |
fe3bb6 |
'externally. Defaults to 127.0.0.1 making the it only visible on localhost')
|
|
Pierre-Yves Chibon |
d04562 |
|
|
Pierre-Yves Chibon |
d04562 |
args = parser.parse_args()
|
|
Pierre-Yves Chibon |
d04562 |
|
|
Pierre-Yves Chibon |
d04562 |
if args.config:
|
|
Pierre-Yves Chibon |
0dcb38 |
config = args.config
|
|
Pierre-Yves Chibon |
0dcb38 |
if not config.startswith('/'):
|
|
Pierre-Yves Chibon |
0dcb38 |
here = os.path.join(os.path.dirname(os.path.abspath(__file__)))
|
|
Pierre-Yves Chibon |
0dcb38 |
config = os.path.join(here, config)
|
|
Pierre-Yves Chibon |
0dcb38 |
os.environ['PAGURE_CONFIG'] = config
|
|
Pierre-Yves Chibon |
182e33 |
|
|
Pierre-Yves Chibon |
94ab5a |
from pagure import APP
|
|
Pierre-Yves Chibon |
94ab5a |
|
|
Pierre-Yves Chibon |
94ab5a |
if args.profile:
|
|
Pierre-Yves Chibon |
94ab5a |
from werkzeug.contrib.profiler import ProfilerMiddleware
|
|
Pierre-Yves Chibon |
94ab5a |
APP.config['PROFILE'] = True
|
|
Pierre-Yves Chibon |
94ab5a |
APP.wsgi_app = ProfilerMiddleware(APP.wsgi_app, restrictions=[30])
|
|
Pierre-Yves Chibon |
94ab5a |
|
|
Pierre-Yves Chibon |
182e33 |
APP.debug = True
|
|
Ryan Lerch |
73a5b2 |
APP.run(host=args.host, port=int(args.port))
|