Skip to content

Commit

Permalink
Merge pull request #110 from beabee-communityrm/fix/cron-overload
Browse files Browse the repository at this point in the history
fix: randomise cron times to reduce server overload
  • Loading branch information
wpf500 authored Dec 17, 2024
2 parents 07c8364 + 6ed049d commit 3adb514
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions apps/backend/crontab
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Add node to the PATH
PATH=/usr/local/bin:/usr/bin:/bin

# min hour day month weekday command
0 1 * * * su node -c 'cd /opt/apps/backend/ && node ./built/tools/mailchimp/sync.js' > /proc/1/fd/1 2>&1
0 1 * * * su node -c 'cd /opt/apps/backend/ && node ./built/tools/start-gifts.js' > /proc/1/fd/1 2>&1
0 1 * * * su node -c 'cd /opt/apps/backend/ && node ./built/tools/process-segments.js' > /proc/1/fd/1 2>&1
# Spread the jobs out over a few minutes to avoid overloading the server
0 1 * * * su node -c 'cd /opt/apps/backend/ && sleep $((RANDOM \% 120)) && node ./built/tools/mailchimp/sync.js' > /proc/1/fd/1 2>&1
5 1 * * * su node -c 'cd /opt/apps/backend/ && sleep $((RANDOM \% 120)) && node ./built/tools/start-gifts.js' > /proc/1/fd/1 2>&1
10 1 * * * su node -c 'cd /opt/apps/backend/ && sleep $((RANDOM \% 120)) && node ./built/tools/process-segments.js' > /proc/1/fd/1 2>&1

0 comments on commit 3adb514

Please sign in to comment.