Skip to content

Commit c2d8697

Browse files
aequitasmxsasha
authored andcommitted
Add cron with docker socket to restart nassl worker every hour
1 parent 89bf57b commit c2d8697

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

docker/docker-compose.yml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -320,6 +320,23 @@ services:
320320
command: celery --app internetnl worker --without-gossip --pool=eventlet --time-limit=300 --concurrency=$WORKER_CONCURRENCY
321321
--queues nassl_worker
322322

323+
# cron daemon with access to Docker socket to restart worker-nassl periodically to solve memory issues
324+
restart-nassl-worker:
325+
image: alpinelinux/docker-cli:latest
326+
command: crond -f -d7
327+
configs:
328+
- source: restart_nassl_worker_cron
329+
target: /etc/periodic/hourly/restart_nassl_worker
330+
mode: 0755
331+
restart: unless-stopped
332+
logging:
333+
driver: $LOGGING_DRIVER
334+
options:
335+
tag: '{{.Name}}'
336+
network_mode: "none"
337+
volumes:
338+
- /var/run/docker.sock:/var/run/docker.sock
339+
323340
# worker for slow and long running tasks that could require a lot of memory (eg: hof update)
324341
worker-slow:
325342
# copy all attributes from 'worker' service and overwrite specific settings below
@@ -882,6 +899,12 @@ configs:
882899
}
883900
884901
902+
restart_nassl_worker_cron:
903+
content: |
904+
#!/bin/sh
905+
set -e
906+
# find nassl worker and restart the container
907+
docker restart $(docker ps --filter label=com.docker.compose.service=worker-nassl --quiet)
885908
886909
networks:
887910
# disable default network

0 commit comments

Comments
 (0)