This repository has been archived by the owner on Jun 12, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathrun.py
executable file
·39 lines (33 loc) · 1.77 KB
/
run.py
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
#!./venv/bin/python
# -*- coding: utf-8 -*-
import argparse
import logging
from app.app import create_app
from werkzeug.serving import WSGIRequestHandler
parser = argparse.ArgumentParser(
description='Gatekeeper is a service to install and manage gates in build pipelines.')
parser.add_argument('-p', '--port', nargs='?', default=8080,
help='Port: Specify port. Default is 8080')
parser.add_argument('-e', '--env', nargs='?', default="local",
help='Environment: Specify which config to load. Default is local.')
parser.add_argument('-w', '--workdir', nargs='?', default="./",
help='Workdir: Specify which working directory to use. Default is the local directory')
parser.add_argument('-g', '--greedy', action='store_true',
help='Greedy: Run processes once (synchron) and then start to serve.')
parser.add_argument('-v', '--verbose', nargs='?', const="DEBUG", default="WARN",
help='Lets you set the loglevel. Application default: WARN. Option default: DEBUG') # without param->const. If no present->default
args = parser.parse_args()
log_level = logging.getLevelName(args.verbose)
logging.basicConfig(level=log_level,
datefmt='%d-%m %H:%M:%S',
format='%(asctime)s %(name)-s %(levelname)-s %(message)s')
print("\n\x1b[32mApplication starting...\x1b[0m")
print(" Port: " + str(args.port))
print(" Environment: " + str(args.env))
print(" Workdir: " + str(args.workdir))
print(" Greedy: " + str(args.greedy))
print(" Logging: " + str(args.verbose))
print("\x1b[32m========================\x1b[0m")
app = create_app(port=int(args.port), environment=args.env)
if __name__ == "__main__":
app.run(debug=True, use_reloader=False, port=int(args.port), host='0.0.0.0')