45 lines
1.5 KiB
Python
Executable File
45 lines
1.5 KiB
Python
Executable File
from argparse import ArgumentParser
|
|
import yaml
|
|
from jellyseer_exporter.http import start_http_server
|
|
from jellyseer_exporter.config import config_from_yaml
|
|
from jellyseer_exporter.collector import CollectorsOptions
|
|
|
|
|
|
def main():
|
|
"""
|
|
Main entry point.
|
|
"""
|
|
|
|
parser = ArgumentParser()
|
|
parser.add_argument('config', nargs='?', default='jellyseer.yml',
|
|
help='Path to configuration file (jellyseer.yml)')
|
|
parser.add_argument('port', nargs='?', type=int, default='9223',
|
|
help='Port on which the exporter is listening (9223)')
|
|
parser.add_argument('address', nargs='?', default='',
|
|
help='Address to which the exporter will bind')
|
|
parser.add_argument('--server.keyfile', dest='server_keyfile',
|
|
help='SSL key for server')
|
|
parser.add_argument('--server.certfile', dest='server_certfile',
|
|
help='SSL certificate for server')
|
|
|
|
params = parser.parse_args()
|
|
|
|
collectors = CollectorsOptions(
|
|
sessions=True
|
|
)
|
|
|
|
with open(params.config, encoding='utf-8') as handle:
|
|
config = config_from_yaml(yaml.safe_load(handle))
|
|
|
|
gunicorn_options = {
|
|
'bind': f'{params.address}:{params.port}',
|
|
'threads': 2,
|
|
'keyfile': params.server_keyfile,
|
|
'certfile': params.server_certfile,
|
|
}
|
|
|
|
if config.valid:
|
|
start_http_server(config, gunicorn_options, collectors)
|
|
else:
|
|
parser.error(str(config))
|