Check config and fail early

This commit is contained in:
Esteban Sánchez 2020-09-29 11:45:56 +02:00
parent fb767eba1e
commit 6007908113

View file

@ -1,6 +1,6 @@
from httplib2 import Http
import time
import os
import sys
import signal
import faulthandler
from qbittorrentapi import Client, TorrentStates
@ -186,6 +186,14 @@ def main():
logger.addHandler(logHandler)
logger.setLevel(config["log_level"])
if not config["host"]:
logger.error("No host specified, please set QBITTORRENT_HOST environment variable")
sys.exit(1)
if not config["post"]:
logger.error("No post specified, please set QBITTORRENT_PORT environment variable")
sys.exit(1)
# Register our custom collector
logger.info("Exporter is starting up")
REGISTRY.register(QbittorrentMetricsCollector(config))