-
Notifications
You must be signed in to change notification settings - Fork 37
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor worker restart to prevent issues with periodic tests
- Loading branch information
Showing
4 changed files
with
41 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,8 @@ | ||
#!/bin/sh | ||
set -e | ||
# find nassl worker and restart the container(s) | ||
docker ps --filter label=com.docker.compose.service=worker-nassl --quiet | xargs --no-run-if-empty docker restart | ||
# stop and start worker one at a time to ensure (batch) tasks are still being picked up | ||
# workers are sent a TERM signal with which a 10 minute grace period before QUIT is sent | ||
for worker in $(docker ps --filter label=com.docker.compose.service=worker-nassl --quiet); do | ||
docker stop "$$worker" | ||
docker start "$$worker" | ||
done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
#!/bin/sh | ||
|
||
# restart slow worker every day to prevent slow memory leaks | ||
# as the slow worker can run very long tasks (eg: report generation) | ||
# we first start a new container before stopping the previous one | ||
|
||
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 --no-recreate --wait --scale="$SERVICE=$(($REPLICAS*2))" "$SERVICE" | ||
|
||
# graceful shutdown and remove old containers | ||
docker rm --force "$OLD_CONTAINERS" | ||
|
||
# restore replica number to original | ||
$COMPOSE_CMD scale $SERVICE=$REPLICAS |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,8 @@ | ||
#!/bin/sh | ||
set -e | ||
# find worker and restart the container(s) | ||
docker ps --filter label=com.docker.compose.service=worker --quiet | xargs --no-run-if-empty docker restart | ||
# stop and start worker one at a time to ensure (batch) tasks are still being picked up | ||
# workers are sent a TERM signal with which a 10 minute grace period before QUIT is sent | ||
for worker in $(docker ps --filter label=com.docker.compose.service=worker --quiet); do | ||
docker stop "$$worker" | ||
docker start "$$worker" | ||
done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters