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 a47caea
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,6 +728,9 @@ 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
Expand Down Expand Up @@ -772,6 +775,7 @@ services:
# disables live functionality which is not used, because it uses websockets which don't play well with authentication
- GF_LIVE_MAX_CONNECTIONS=0
- INTERNETNL_DOMAINNAME
- WORKER_SLOW_REPLICAS

volumes:
- grafana-data:/var/lib/grafana
Expand Down

0 comments on commit a47caea

Please sign in to comment.