37 lines
1.3 KiB
Shell
37 lines
1.3 KiB
Shell
|
|
#!/bin/sh
|
||
|
|
# Rests the instance's heavy sidecars during the CI runner's nightly window and starts them
|
||
|
|
# again after it (ADR 0039, D6): `night.sh stop` at 01:55, `night.sh start` at 05:00, as
|
||
|
|
# deploy, from deploy/runner/'s halkyon-night and halkyon-morning units. Caddy, PostgreSQL
|
||
|
|
# and the apps' servers keep serving through the night, so people sign in and sync;
|
||
|
|
# Jellyfin, LanguageTool, the dictionaries, routes, map tiles and place search, with their
|
||
|
|
# refreshers, wait until the morning. Only those .env switches on; a deploy in between
|
||
|
|
# starts them with the rest, which is harmless.
|
||
|
|
set -eu
|
||
|
|
|
||
|
|
# Every service that takes memory or builds data, by its compose name.
|
||
|
|
heavy="jellyfin languagetool dictionaries brouter brouter-segments map-tiles map-tiles-refresh photon photon-data"
|
||
|
|
|
||
|
|
cd "$(dirname "$0")"
|
||
|
|
action=${1:-}
|
||
|
|
case $action in
|
||
|
|
stop | start) ;;
|
||
|
|
*)
|
||
|
|
echo "usage: $0 stop|start" >&2
|
||
|
|
exit 2
|
||
|
|
;;
|
||
|
|
esac
|
||
|
|
|
||
|
|
on=$(docker compose config --services)
|
||
|
|
services=
|
||
|
|
for service in $heavy; do
|
||
|
|
if printf '%s\n' "$on" | grep -qx "$service"; then
|
||
|
|
services="$services $service"
|
||
|
|
fi
|
||
|
|
done
|
||
|
|
if [ -z "$services" ]; then
|
||
|
|
echo "No heavy sidecar is switched on."
|
||
|
|
exit 0
|
||
|
|
fi
|
||
|
|
# shellcheck disable=SC2086 # one service a word
|
||
|
|
docker compose "$action" $services
|
||
|
|
echo "night.sh $action:$services"
|