|
| 1 | +#!/usr/bin/env python3 |
| 2 | +#PBR Generated from 'wsgi_scripts' - Archived for Octavia stable branches |
| 3 | + |
| 4 | +import threading |
| 5 | + |
| 6 | +from octavia.api.app import setup_app |
| 7 | + |
| 8 | +if __name__ == "__main__": |
| 9 | + import argparse |
| 10 | + import socket |
| 11 | + import sys |
| 12 | + import wsgiref.simple_server as wss |
| 13 | + |
| 14 | + parser = argparse.ArgumentParser( |
| 15 | + description=setup_app.__doc__, |
| 16 | + formatter_class=argparse.ArgumentDefaultsHelpFormatter, |
| 17 | + usage='%(prog)s [-h] [--port PORT] [--host IP] -- [passed options]') |
| 18 | + parser.add_argument('--port', '-p', type=int, default=8000, |
| 19 | + help='TCP port to listen on') |
| 20 | + parser.add_argument('--host', '-b', default='', |
| 21 | + help='IP to bind the server to') |
| 22 | + parser.add_argument('args', |
| 23 | + nargs=argparse.REMAINDER, |
| 24 | + metavar='-- [passed options]', |
| 25 | + help="'--' is the separator of the arguments used " |
| 26 | + "to start the WSGI server and the arguments passed " |
| 27 | + "to the WSGI application.") |
| 28 | + args = parser.parse_args() |
| 29 | + if args.args: |
| 30 | + if args.args[0] == '--': |
| 31 | + args.args.pop(0) |
| 32 | + else: |
| 33 | + parser.error("unrecognized arguments: %s" % ' '.join(args.args)) |
| 34 | + sys.argv[1:] = args.args |
| 35 | + server = wss.make_server(args.host, args.port, setup_app()) |
| 36 | + |
| 37 | + print("*" * 80) |
| 38 | + print("STARTING test server octavia.api.app.setup_app") |
| 39 | + url = "http://%s:%d/" % (server.server_name, server.server_port) |
| 40 | + print("Available at %s" % url) |
| 41 | + print("DANGER! For testing only, do not use in production") |
| 42 | + print("*" * 80) |
| 43 | + sys.stdout.flush() |
| 44 | + |
| 45 | + server.serve_forever() |
| 46 | +else: |
| 47 | + application = None |
| 48 | + app_lock = threading.Lock() |
| 49 | + |
| 50 | + with app_lock: |
| 51 | + if application is None: |
| 52 | + application = setup_app() |
0 commit comments