|
Neal Gompa |
55fa35 |
#!/usr/bin/env python
|
|
Pierre-Yves Chibon |
2088eb |
|
|
Pierre-Yves Chibon |
67d1cc |
from __future__ import unicode_literals, absolute_import
|
|
Aurélien Bompard |
dcf6f6 |
|
|
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 |
0f6d83 |
'--plugins', dest='plugins',
|
|
Pierre-Yves Chibon |
0f6d83 |
help='Configuration file for pagure plugin.')
|
|
Pierre-Yves Chibon |
0f6d83 |
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(
|
|
Patrick Uiterwijk |
571575 |
'--perf-verbose', dest='perfverbose', action='store_true',
|
|
Patrick Uiterwijk |
571575 |
default=False,
|
|
Patrick Uiterwijk |
571575 |
help='Enable per-request printing of performance statistics.')
|
|
Patrick Uiterwijk |
571575 |
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(
|
|
Patrick Uiterwijk |
62924b |
'--no-debug', action='store_true',
|
|
Patrick Uiterwijk |
62924b |
help='Disable debugging')
|
|
Patrick Uiterwijk |
62924b |
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 |
0f6d83 |
if args.plugins:
|
|
Pierre-Yves Chibon |
0f6d83 |
config = args.plugins
|
|
Pierre-Yves Chibon |
0f6d83 |
if not config.startswith('/'):
|
|
Pierre-Yves Chibon |
0f6d83 |
here = os.path.join(os.path.dirname(os.path.abspath(__file__)))
|
|
Pierre-Yves Chibon |
0f6d83 |
config = os.path.join(here, config)
|
|
Pierre-Yves Chibon |
0f6d83 |
os.environ['PAGURE_PLUGIN'] = config
|
|
Pierre-Yves Chibon |
0f6d83 |
|
|
Patrick Uiterwijk |
571575 |
if args.perfverbose:
|
|
Patrick Uiterwijk |
571575 |
os.environ['PAGURE_PERFREPO'] = 'true'
|
|
Patrick Uiterwijk |
571575 |
os.environ['PAGURE_PERFREPO_VERBOSE'] = 'true'
|
|
Patrick Uiterwijk |
571575 |
|
|
Pierre-Yves Chibon |
b130e5 |
from pagure.flask_app import create_app
|
|
Pierre-Yves Chibon |
b130e5 |
|
|
Pierre-Yves Chibon |
b130e5 |
APP = create_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 |
|
|
Patrick Uiterwijk |
62924b |
APP.debug = not args.no_debug
|
|
Ryan Lerch |
73a5b2 |
APP.run(host=args.host, port=int(args.port))
|