@@ -23,6 +23,25 @@ REDIS_PID_FILE="./redis.pid"
2323echo -e " ${BLUE} 🚀 BasicChat Enhanced Startup Script${NC} "
2424echo " =================================="
2525
26+ # Show cool ASCII animation/logo at startup
27+ ascii_logo=(
28+ " ____ _ _ _____ _ _ "
29+ " | _ \\ | | | | / ____| | | | "
30+ " | |_) | __ _ ___| | __ | | | | | |__ __ _| |_ "
31+ " | _ < / _\` / __| |/ / | | | | | '_ \\ / _\` | __|"
32+ " | |_) | (_| \\ __ \\ < | |___| |____| | | | (_| | |_ "
33+ " |____/ \\ __,_|___/_|\\ _\\ |______\\ _____|_| |_|\\ __,_|\\ __|"
34+ )
35+
36+ for line in " ${ascii_logo[@]} " ; do
37+ for (( i= 0 ; i< ${# line} ; i++ )) ; do
38+ echo -ne " \033[1;36m${line: $i : 1} \033[0m"
39+ sleep 0.002
40+ done
41+ echo
42+ sleep 0.03
43+ done
44+
2645# Function to print colored output
2746print_status () {
2847 echo -e " ${GREEN} ✅ $1 ${NC} "
@@ -50,28 +69,43 @@ check_port() {
5069 fi
5170}
5271
53- # Function to wait for service to be ready
72+ # Spinner function for animated feedback
73+ spinner () {
74+ local pid=$1
75+ local msg=" $2 "
76+ local spin=' |/-\\'
77+ local i=0
78+ tput civis 2> /dev/null # Hide cursor
79+ while kill -0 $pid 2> /dev/null; do
80+ i=$(( (i+ 1 ) % 4 ))
81+ printf " \r\033[1;36m%s %s\033[0m" " ${spin: $i : 1} " " $msg "
82+ sleep 0.1
83+ done
84+ printf " \r\033[1;32m✔ %s\033[0m\n" " $msg "
85+ tput cnorm 2> /dev/null # Show cursor
86+ }
87+
88+ # Enhanced wait_for_service with spinner
5489wait_for_service () {
55- local service_name=$1
56- local port=$2
57- local max_attempts=30
58- local attempt=1
59-
60- print_info " Waiting for $service_name to be ready on port $port ..."
61-
62- while [ $attempt -le $max_attempts ]; do
63- if check_port $port ; then
64- print_status " $service_name is ready!"
65- return 0
66- fi
67-
68- echo -n " ."
69- sleep 1
70- attempt=$(( attempt + 1 ))
71- done
72-
73- print_error " $service_name failed to start within $max_attempts seconds"
74- return 1
90+ local service_name=$1
91+ local port=$2
92+ local max_attempts=30
93+ local attempt=1
94+ local spin=' |/-\\'
95+ local i=0
96+ print_info " Waiting for $service_name to be ready on port $port ..."
97+ while [ $attempt -le $max_attempts ]; do
98+ if check_port $port ; then
99+ printf " \r\033[1;32m✔ %s is ready!\033[0m\n" " $service_name "
100+ return 0
101+ fi
102+ i=$(( (i+ 1 ) % 4 ))
103+ printf " \r\033[1;36m%s Waiting for %s...\033[0m" " ${spin: $i : 1} " " $service_name "
104+ sleep 0.2
105+ attempt=$(( attempt + 1 ))
106+ done
107+ printf " \r\033[1;31m✖ %s failed to start within %s seconds\033[0m\n" " $service_name " " $max_attempts "
108+ return 1
75109}
76110
77111# Function to start Redis
0 commit comments