Skip to content

Commit 9631f37

Browse files
wenxi-onyxWenxi Onyxgreptile-apps[bot]
authored
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>
1 parent cbd4d46 commit 9631f37

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

backend/scripts/restart_containers.sh

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,14 @@
11
#!/bin/bash
2+
set -e
3+
4+
cleanup() {
5+
echo "Error occurred. Cleaning up..."
6+
docker stop onyx_postgres onyx_vespa onyx_redis 2>/dev/null || true
7+
docker rm onyx_postgres onyx_vespa onyx_redis 2>/dev/null || true
8+
}
9+
10+
# Trap errors and output a message, then cleanup
11+
trap 'echo "Error occurred on line $LINENO. Exiting script." >&2; cleanup' ERR
212

313
# Usage of the script with optional volume arguments
414
# ./restart_containers.sh [vespa_volume] [postgres_volume] [redis_volume]

0 commit comments

Comments
 (0)