Skip to content

Commit

Permalink
[release] Restart timer ready, docker examples updated
Browse files Browse the repository at this point in the history
  • Loading branch information
Feramance committed Sep 27, 2023
1 parent 8315d33 commit dbb95b7
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 9 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ The docker image can be found [here](https://hub.docker.com/r/feramance/qbitrr)
docker run -d \
--name=qbitrr \
-e TZ=Europe/London \
-e RESTART_TIMER=0 \
-v /etc/localtime:/etc/localtime:ro \
-v /path/to/appdata/qbitrr:/config \
-v /path/to/sonarr/db:/databases/sonarr.db:ro \
Expand All @@ -120,6 +121,7 @@ services:
# networks: This container MUST share a network with your Sonarr/Radarr instances
environment:
- TZ=Europe/London
- RESTART_TIMER=0 #Number of hours after which to restart the child processes (default=0, set 0 to disable)
volumes:
- /etc/localtime:/etc/localtime:ro
- /path/to/appdata/qbitrr:/config # Config folder for qBitrr
Expand Down
23 changes: 14 additions & 9 deletions qBitrr/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,8 +167,11 @@ def run():
if early_exit is True:
sys.exit(0)
logger.info("Starting qBitrr: Version: %s.", patched_version)
delay = os.getenv("RESTART_TIMER", 24)
logger.info("Restart timer is set to %s hours", delay)
delay = os.getenv("RESTART_TIMER", 0)
if delay == 0:
logger.info("Restart timer is disabled")
else:
logger.info("Restart timer is set to %s hours", delay)
manager = qBitManager()
run_logs(logger)
logger.debug("Environment variables: %r", ENVIRO_CONFIG)
Expand Down Expand Up @@ -205,10 +208,12 @@ def cleanup():
if __name__ == "__main__":
freeze_support()
run()
delay = os.getenv("RESTART_TIMER", 24)
loop_delay = datetime.now() + timedelta(hours=delay)
while True:
if datetime.now() == loop_delay:
cleanup()
run()
loop_delay = datetime.now() + timedelta(hours=delay)
delay = os.getenv("RESTART_TIMER", 0)
if delay != 0:
loop_delay = datetime.now() + timedelta(hours=delay)
while True:
if datetime.now() == loop_delay:
logger.info("Restarting processes", delay)
cleanup()
run()
loop_delay = datetime.now() + timedelta(hours=delay)

0 comments on commit dbb95b7

Please sign in to comment.