|
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 |
73d120 |
__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 |
73d120 |
parser = argparse.ArgumentParser(description="Run the Pagure doc server")
|
|
Pierre-Yves Chibon |
5274cc |
parser.add_argument(
|
|
Pierre-Yves Chibon |
73d120 |
"--config",
|
|
Pierre-Yves Chibon |
73d120 |
"-c",
|
|
Pierre-Yves Chibon |
73d120 |
dest="config",
|
|
Pierre-Yves Chibon |
73d120 |
help="Configuration file to use for the pagure doc server.",
|
|
Pierre-Yves Chibon |
73d120 |
)
|
|
Pierre-Yves Chibon |
5274cc |
parser.add_argument(
|
|
Pierre-Yves Chibon |
73d120 |
"--debug",
|
|
Pierre-Yves Chibon |
73d120 |
dest="debug",
|
|
Pierre-Yves Chibon |
73d120 |
action="store_true",
|
|
Pierre-Yves Chibon |
5274cc |
default=False,
|
|
Pierre-Yves Chibon |
73d120 |
help="Expand the level of data returned.",
|
|
Pierre-Yves Chibon |
73d120 |
)
|
|
Pierre-Yves Chibon |
5274cc |
parser.add_argument(
|
|
Pierre-Yves Chibon |
73d120 |
"--profile",
|
|
Pierre-Yves Chibon |
73d120 |
dest="profile",
|
|
Pierre-Yves Chibon |
73d120 |
action="store_true",
|
|
Pierre-Yves Chibon |
5274cc |
default=False,
|
|
Pierre-Yves Chibon |
73d120 |
help="Profile the doc server.",
|
|
Pierre-Yves Chibon |
73d120 |
)
|
|
Pierre-Yves Chibon |
5274cc |
parser.add_argument(
|
|
Pierre-Yves Chibon |
73d120 |
"--port",
|
|
Pierre-Yves Chibon |
73d120 |
"-p",
|
|
Pierre-Yves Chibon |
73d120 |
default=5001,
|
|
Pierre-Yves Chibon |
73d120 |
help="Port for the Pagure doc server to run on.",
|
|
Pierre-Yves Chibon |
73d120 |
)
|
|
Pierre-Yves Chibon |
5274cc |
parser.add_argument(
|
|
Pierre-Yves Chibon |
73d120 |
"--host",
|
|
Pierre-Yves Chibon |
73d120 |
default="127.0.0.1",
|
|
Pierre-Yves Chibon |
73d120 |
help="Hostname to listen on. When set to 0.0.0.0 the server is "
|
|
Pierre-Yves Chibon |
73d120 |
"available externally. Defaults to 127.0.0.1 making the it only "
|
|
Pierre-Yves Chibon |
73d120 |
"visible on localhost",
|
|
Pierre-Yves Chibon |
73d120 |
)
|
|
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 |
73d120 |
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 |
73d120 |
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 |
73d120 |
|
|
Pierre-Yves Chibon |
73d120 |
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))
|