Skip to content

Commit

Permalink
Slow worker restart
Browse files Browse the repository at this point in the history
  • Loading branch information
aequitas committed Oct 21, 2024
1 parent 5ea5af9 commit 98dd695
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
19 changes: 19 additions & 0 deletions docker/cron-docker/periodic/daily/restart_slow_worker_cron
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#!/bin/sh
set -e

cd /opt/Internet.nl

SERVICE=worker-slow
REPLICAS=$WORKER_SLOW_REPLICAS
COMPOSE_CMD="docker compose --env-file=docker/defaults.env --env-file=docker/host.env --env-file=docker/local.env"

OLD_CONTAINERS=$($COMPOSE_CMD ps --format "{{ .Name }}"|grep "$SERVICE")

# bring up new containers, wait until healthy
$COMPOSE_CMD up --no-deps --wait --scale=$(($REPLICAS*2)) up "$SERVICE"

# graceful shutdown and remove old containers
docker rm --force "$OLD_CONTAINERS"

# restore replica number to original
$COMPOSE_CMD scale $SERVICE=$REPLICAS
4 changes: 4 additions & 0 deletions docker/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -728,9 +728,13 @@ services:
# cron daemon with access to Docker socket but no networking
cron-docker:
image: ${DOCKER_IMAGE_UTIL:-${DOCKER_REGISTRY:-ghcr.io/internetstandards}/util:${RELEASE}}
build:
context: ..
dockerfile: docker/util.Dockerfile
command: crond -f -d7 -c /etc/crontabs-docker
environment:
- AUTO_UPDATE_TO
- WORKER_SLOW_REPLICAS

restart: unless-stopped
logging:
Expand Down

0 comments on commit 98dd695

Please sign in to comment.