From 6007908113e8cb99a97c4b87a2a40c8eabaabc5f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Esteban=20S=C3=A1nchez?= Date: Tue, 29 Sep 2020 11:45:56 +0200 Subject: [PATCH] Check config and fail early --- qbittorrent_exporter/exporter.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/qbittorrent_exporter/exporter.py b/qbittorrent_exporter/exporter.py index 8405895..cb1a4f9 100644 --- a/qbittorrent_exporter/exporter.py +++ b/qbittorrent_exporter/exporter.py @@ -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))