Improvements to docker scheduling and lock file (#339)

* improved logic that prevents overlapping runs, added logic to kill the process if it is stuck or doesn't exit properly

* Improve lock file logic

Improve lock file logic to release lock if the script didn't finish cleanly on a prior run. Otherwise shouldn't interrupt actual run.

* Tidy up readme for docker
This commit is contained in:
Michael Cammarata
2025-09-10 03:29:28 -04:00
committed by GitHub
parent eea4407454
commit 072e96dd53
3 changed files with 138 additions and 30 deletions

View File

@@ -1,5 +1,5 @@
services:
netsky:
microsoft-rewards-script:
build: .
container_name: microsoft-rewards-script
restart: unless-stopped
@@ -14,13 +14,16 @@ services:
TZ: "America/Toronto" # Set your timezone for proper scheduling
NODE_ENV: "production"
CRON_SCHEDULE: "0 7,16,20 * * *" # Customize your schedule, use crontab.guru for formatting
RUN_ON_START: "true" # Runs the script on container startup
RUN_ON_START: "true" # Runs the script immediately on container startup
# Start-time randomization (uncomment to customize or disable)
# Add scheduled start-time randomization (uncomment to customize or disable, default: enabled)
#MIN_SLEEP_MINUTES: "5"
#MAX_SLEEP_MINUTES: "50"
SKIP_RANDOM_SLEEP: "false"
# Optionally set how long to wait before killing a stuck script run (prevents blocking future runs, default: 8 hours)
#STUCK_PROCESS_TIMEOUT_HOURS: "8"
# Optional resource limits for the container
mem_limit: 4g
cpus: 2