-
Notifications
You must be signed in to change notification settings - Fork 1
/
fus-api
executable file
·40 lines (32 loc) · 1.45 KB
/
fus-api
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#!/usr/bin/env python
"""
Entry point for starting a local test Fusillade API server.
"""
import argparse
import logging
import os
import sys
from chalice.cli import CLIFactory
parser = argparse.ArgumentParser(description=__doc__)
parser.add_argument("--host", default="localhost")
parser.add_argument("--port", type=int, default=5000)
parser.add_argument("--no-debug", dest="debug", action="store_false",
help="Disable Chalice/Connexion/Flask debug mode")
parser.add_argument("--project-dir", help=argparse.SUPPRESS,
default=os.path.join(os.path.dirname(__file__)))
parser.add_argument("--log-level",
help=str([logging.getLevelName(i) for i in range(0, 60, 10)]),
choices={logging.getLevelName(i) for i in range(0, 60, 10)},
default=logging.DEBUG)
args = parser.parse_args()
if "FUS_HOME" not in os.environ:
parser.exit('Please run "source environment" in the fusillade repo root directory')
logging.basicConfig(level=args.log_level, stream=sys.stderr)
factory = CLIFactory(project_dir=args.project_dir, debug=args.debug)
# The following code snippet is basically stolen from chalice/__init__py:run_local_server
config = factory.create_config_obj(
chalice_stage_name=os.environ["FUS_DEPLOYMENT_STAGE"]
)
app_obj = factory.load_chalice_app()
server = factory.create_local_server(app_obj=app_obj, config=config, host=args.host, port=args.port)
server.serve_forever()