Skip to content

Commit a7f8fc4

Browse files
authored
Update cron example configs to match production (#860)
1 parent e164458 commit a7f8fc4

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

documentation/example_configuration/opt_internetnl_etc/cron/batch_crontab

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,9 @@
44
# Batch scans come in huge numbers, so there is a need for more frequent restarts. Given tasks are acked late, and the
55
# workers are stopped gracefully no tasks are losts doing this. Suppose we'll want to do 10.000 scans an hour, we'll
66
# have to reset every 30 minutes or so.
7-
*/30 * * * * /opt/internetnl/etc/cron/batch_restart_services.sh
7+
# However, in Jan 2023 we discovered that in production we only did this every 6 hours,
8+
# still exceeding the connection limit. The restart every 6 hrs was reflected here,
9+
# along with a new script that restarts based on number of Redis connections.
10+
0 */6 * * * /opt/internetnl/etc/cron/batch_restart_services.sh
11+
*/3 * * * * /opt/internetnl/etc/cron/restart_redis_gunicorn_on_too_many_connections.sh
812
0 3 * * * /opt/internetnl/etc/cron/restart_gunicorn.sh
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#!/bin/bash
2+
3+
export PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
4+
5+
REDIS_CONS=$(netstat -antlp | grep :6379 | grep "CLOSE_WAIT" | wc -l)
6+
7+
if [ ${REDIS_CONS} -gt 50000 ]; then
8+
logger --tag redis-connections-limit-cron "Redis is having too much connections in CLOSED state. Restarting internetnl batch services"
9+
for i in $(ls -1 /etc/systemd/system/internetnl-batch*.service); do /bin/systemctl restart `basename $i`; done
10+
fi

0 commit comments

Comments
 (0)