Restart script clarity (#4837)

* Add error clarity to restart containers script

* erroneous cleanup on exit

* space

Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>

---------

Co-authored-by: Wenxi Onyx <wenxi-onyx@Wenxis-MacBook-Pro.local>
Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>
This commit is contained in:
Wenxi
2025-06-05 19:24:06 -07:00
committed by GitHub
parent cbd4d46fa5
commit 9631f373f0

View File

@ -1,4 +1,14 @@
#!/bin/bash #!/bin/bash
set -e
cleanup() {
echo "Error occurred. Cleaning up..."
docker stop onyx_postgres onyx_vespa onyx_redis 2>/dev/null || true
docker rm onyx_postgres onyx_vespa onyx_redis 2>/dev/null || true
}
# Trap errors and output a message, then cleanup
trap 'echo "Error occurred on line $LINENO. Exiting script." >&2; cleanup' ERR
# Usage of the script with optional volume arguments # Usage of the script with optional volume arguments
# ./restart_containers.sh [vespa_volume] [postgres_volume] [redis_volume] # ./restart_containers.sh [vespa_volume] [postgres_volume] [redis_volume]