first commit
This commit is contained in:
+52
@@ -0,0 +1,52 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
log() {
|
||||
local message="$1"
|
||||
echo -e "\033[32mLog: $message\033[0m"
|
||||
}
|
||||
|
||||
handle_error() {
|
||||
local error_message="$1"
|
||||
echo -e "\033[31mError: $error_message\033[0m"
|
||||
exit 1
|
||||
}
|
||||
|
||||
retry() {
|
||||
local max_attempts=5
|
||||
local attempt=1
|
||||
local delay=1
|
||||
|
||||
while true; do
|
||||
"$@" && break || {
|
||||
if [ $attempt -lt $max_attempts ]; then
|
||||
log "Command failed (attempt $attempt/$max_attempts). Retrying in $delay seconds..."
|
||||
sleep $delay
|
||||
delay=$((delay * 2))
|
||||
((attempt++))
|
||||
else
|
||||
handle_error "Command failed after $attempt attempts: $*"
|
||||
fi
|
||||
}
|
||||
done
|
||||
}
|
||||
|
||||
|
||||
################################################################################
|
||||
# MAIN
|
||||
################################################################################
|
||||
if [ "$1" == "product" ]; then
|
||||
start_services
|
||||
cd ../product || handle_error "Failed to enter 'product' directory"
|
||||
log "Start client in dev mode"
|
||||
retry docker compose up -d --build
|
||||
|
||||
elif [ "$1" == "helper" ]; then
|
||||
start_services
|
||||
cd ../client || handle_error "Failed to enter 'client' directory"
|
||||
log "Start client in test mode"
|
||||
npm run start:static
|
||||
|
||||
else
|
||||
handle_error "Invalid argument. Use 'dev' or 'test'."
|
||||
fi
|
||||
|
||||
Reference in New Issue
Block a user