playlist_manager: Add --once option

pull/407/head
Mike Lang 2 months ago
parent 9d12d37053
commit d8953568b2

@ -437,6 +437,7 @@ def main(
playlists, playlists,
upload_location_allowlist="youtube", upload_location_allowlist="youtube",
interval=600, interval=600,
once=False,
metrics_port=8007, metrics_port=8007,
backdoor_port=0, backdoor_port=0,
): ):
@ -452,6 +453,7 @@ def main(
upload_location. upload_location.
interval is how often to check for new videos, default every 10min. interval is how often to check for new videos, default every 10min.
If --once is given, interval is ignored and we exit after one check.
""" """
common.PromLogCountsHandler.install() common.PromLogCountsHandler.install()
common.install_stacksampler() common.install_stacksampler()
@ -475,12 +477,15 @@ def main(
dbmanager = DBManager(dsn=dbconnect) dbmanager = DBManager(dsn=dbconnect)
manager = PlaylistManager(dbmanager, client, upload_locations, playlists) manager = PlaylistManager(dbmanager, client, upload_locations, playlists)
while not stop.is_set(): if once:
try: manager.run_once()
manager.run_once() else:
except Exception: while not stop.is_set():
logging.exception("Failed to run playlist manager") try:
manager.reset() manager.run_once()
stop.wait(interval) # wait for interval, or until stopping except Exception:
logging.exception("Failed to run playlist manager")
manager.reset()
stop.wait(interval) # wait for interval, or until stopping
logging.info("Stopped") logging.info("Stopped")

Loading…
Cancel
Save