44GREEN=' \033[0;32m'
55YELLOW=' \033[1;33m'
66RED=' \033[0;31m'
7+ BLUE=' \033[0;34m'
78NC=' \033[0m' # No Color
89
910# Print banner
1011echo -e " ${GREEN} "
1112echo " __ __ _ _"
12- echo " \ \ / / | | | |"
13+ echo " \ \ / / | | | |"
1314echo " \ \ /\ / /__ _ __| | _| | ___ _ __ ____"
1415echo " \ \/ \/ / _ \| '__| |/ / |/ _ \ '_ \|_ /"
1516echo " \ /\ / (_) | | | <| | __/ | | |/ /"
@@ -29,6 +30,51 @@ if [ ! -f .env ]; then
2930 fi
3031fi
3132
33+ # Function to check if a service is running
34+ check_service () {
35+ local service_name=$1
36+ local container_name=$2
37+ local url=$3
38+ local max_attempts=30
39+ local attempt=1
40+
41+ echo -e " ${BLUE} Checking ${service_name} service...${NC} "
42+
43+ # First check if the container is running
44+ while [ $attempt -le $max_attempts ]; do
45+ if docker ps | grep -q " ${container_name} " ; then
46+ # Container is running
47+ if [ -z " $url " ]; then
48+ # No URL to check, assume service is up
49+ echo -e " ${GREEN} ✓${NC} ${service_name} is running"
50+ return 0
51+ else
52+ # Check if service endpoint is responding
53+ if curl -s -f -o /dev/null " $url " ; then
54+ echo -e " ${GREEN} ✓${NC} ${service_name} is running and responding at ${url} "
55+ return 0
56+ else
57+ if [ $attempt -eq $max_attempts ]; then
58+ echo -e " ${YELLOW} ⚠${NC} ${service_name} container is running but not responding at ${url} "
59+ return 1
60+ fi
61+ fi
62+ fi
63+ else
64+ if [ $attempt -eq $max_attempts ]; then
65+ echo -e " ${RED} ✗${NC} ${service_name} failed to start"
66+ return 1
67+ fi
68+ fi
69+
70+ echo -n " ."
71+ attempt=$(( attempt+ 1 ))
72+ sleep 1
73+ done
74+
75+ return 1
76+ }
77+
3278# Check if Docker is installed
3379if ! command -v docker & > /dev/null; then
3480 echo -e " ${RED} Error: Docker is not installed or not in PATH${NC} "
@@ -37,66 +83,72 @@ if ! command -v docker &> /dev/null; then
3783fi
3884
3985# Check if Docker daemon is running
40- echo " Running preflight checks..."
86+ echo -e " ${BLUE} Running preflight checks...${NC} "
4187if ! docker info & > /dev/null; then
4288 echo -e " ${RED} Error: Docker daemon is not running${NC} "
4389 echo " Please start Docker and try again"
4490 exit 1
4591fi
4692echo -e " ${GREEN} ✓${NC} Docker is running"
4793
48- # Check if Docker Compose is installed
49- if ! command -v docker compose & > /dev/null; then
50- echo " Warning: Docker Compose V2 not found, trying docker-compose command..."
51- if ! command -v docker-compose & > /dev/null; then
52- echo " Error: Docker Compose is not installed or not in PATH"
53- echo " Please install Docker Compose: https://docs.docker.com/compose/install/"
54- exit 1
55- fi
56- # Use docker-compose command instead
57- docker-compose down
58- docker-compose up -d
94+ # Determine Docker Compose command to use
95+ DOCKER_COMPOSE_CMD=" "
96+ if command -v docker compose & > /dev/null; then
97+ DOCKER_COMPOSE_CMD=" docker compose"
98+ echo -e " ${GREEN} ✓${NC} Using Docker Compose V2"
99+ elif command -v docker-compose & > /dev/null; then
100+ DOCKER_COMPOSE_CMD=" docker-compose"
101+ echo -e " ${YELLOW} ⚠${NC} Using legacy Docker Compose"
59102else
60- # Use Docker Compose V2
61- docker compose down
62- docker compose up -d
103+ echo -e " ${RED} Error: Docker Compose is not installed or not in PATH ${NC} "
104+ echo " Please install Docker Compose: https://docs.docker.com/compose/install/ "
105+ exit 1
63106fi
64107
65- # Wait for services to be ready
66- echo " Waiting for services to start..."
67- sleep 5
108+ # Check if any of the ports are already in use
109+ ports=(3000 5000 9000 9001 5432)
110+ for port in " ${ports[@]} " ; do
111+ if lsof -i:" $port " > /dev/null 2>&1 ; then
112+ echo -e " ${YELLOW} ⚠ Warning: Port $port is already in use. This may cause conflicts.${NC} "
113+ fi
114+ done
68115
69- # Check if services are running
70- if docker ps | grep -q " worklenz_frontend" ; then
71- echo -e " ${GREEN} ✓${NC} Frontend is running"
72- FRONTEND_URL=" http://localhost:5000"
73- echo " Frontend URL: $FRONTEND_URL "
74- else
75- echo " ✗ Frontend service failed to start"
76- fi
116+ # Start the containers
117+ echo -e " ${BLUE} Starting Worklenz services...${NC} "
118+ $DOCKER_COMPOSE_CMD down
119+ $DOCKER_COMPOSE_CMD up -d
77120
78- if docker ps | grep -q " worklenz_backend" ; then
79- echo -e " ${GREEN} ✓${NC} Backend is running"
80- BACKEND_URL=" http://localhost:3000"
81- echo " Backend URL: $BACKEND_URL "
82- else
83- echo " ✗ Backend service failed to start"
84- fi
121+ # Wait for services to fully initialize
122+ echo -e " ${BLUE} Waiting for services to initialize...${NC} "
123+ echo " This may take a minute or two depending on your system..."
85124
86- if docker ps | grep -q " worklenz_minio" ; then
87- echo -e " ${GREEN} ✓${NC} MinIO is running"
88- MINIO_URL=" http://localhost:9001"
89- echo " MinIO Console URL: $MINIO_URL (login: minioadmin/minioadmin)"
90- else
91- echo " ✗ MinIO service failed to start"
92- fi
125+ # Check each service
126+ check_service " Database" " worklenz_db" " "
127+ DB_STATUS=$?
128+
129+ check_service " MinIO" " worklenz_minio" " http://localhost:9000/minio/health/live"
130+ MINIO_STATUS=$?
131+
132+ check_service " Backend" " worklenz_backend" " http://localhost:3000/api/health"
133+ BACKEND_STATUS=$?
134+
135+ check_service " Frontend" " worklenz_frontend" " http://localhost:5000"
136+ FRONTEND_STATUS=$?
137+
138+ # Display service URLs
139+ echo -e " \n${BLUE} Service URLs:${NC} "
140+ [ $FRONTEND_STATUS -eq 0 ] && echo " • Frontend: http://localhost:5000"
141+ [ $BACKEND_STATUS -eq 0 ] && echo " • Backend API: http://localhost:3000"
142+ [ $MINIO_STATUS -eq 0 ] && echo " • MinIO Console: http://localhost:9001 (login: minioadmin/minioadmin)"
93143
94- if docker ps | grep -q " worklenz_db" ; then
95- echo -e " ${GREEN} ✓${NC} Database is running"
144+ # Check if all services are up
145+ if [ $DB_STATUS -eq 0 ] && [ $MINIO_STATUS -eq 0 ] && [ $BACKEND_STATUS -eq 0 ] && [ $FRONTEND_STATUS -eq 0 ]; then
146+ echo -e " \n${GREEN} ✅ All Worklenz services are running successfully!${NC} "
96147else
97- echo " ✗ Database service failed to start"
148+ echo -e " \n${YELLOW} ⚠ Some services may not be running properly. Check the logs for more details:${NC} "
149+ echo " $DOCKER_COMPOSE_CMD logs"
98150fi
99151
100- echo -e " \n${GREEN} Worklenz is now running! ${NC} "
101- echo " You can access the application at: http://localhost:5000 "
102- echo " To stop the services, run: docker compose down "
152+ echo -e " \n${BLUE} Useful commands: ${NC} "
153+ echo " • View logs: $DOCKER_COMPOSE_CMD logs -f "
154+ echo " • Stop services: ./stop.sh "
0 commit comments