Skip to content

Commit cb94b19

Browse files
authored
Merge pull request #79 from chamikaJ/react-version
Update README.md and scripts for improved setup and service management
2 parents 1d02313 + 50c4f1a commit cb94b19

3 files changed

Lines changed: 141 additions & 58 deletions

File tree

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ These instructions will help you set up and run the Worklenz project on your loc
6262

6363
1. Clone the repository
6464
```bash
65-
git clone https://github.com/yourusername/worklenz.git
65+
git clone https://github.com/Worklenz/worklenz.git
6666
cd worklenz
6767
```
6868

@@ -124,7 +124,7 @@ The project includes a fully configured Docker setup with:
124124

125125
1. Clone the repository:
126126
```bash
127-
git clone https://github.com/yourusername/worklenz.git
127+
git clone https://github.com/Worklenz/worklenz.git
128128
cd worklenz
129129
```
130130

@@ -272,8 +272,8 @@ The project includes a fully configured Docker setup with:
272272

273273
1. Clone the repository:
274274
```bash
275-
git clone https://github.com/yourusername/worklenz-react-v1.git
276-
cd worklenz-react-v1
275+
git clone https://github.com/Worklenz/worklenz.git
276+
cd worklenz
277277
```
278278

279279
2. Start the Docker containers (choose one option):

start.sh

100644100755
Lines changed: 99 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,13 @@
44
GREEN='\033[0;32m'
55
YELLOW='\033[1;33m'
66
RED='\033[0;31m'
7+
BLUE='\033[0;34m'
78
NC='\033[0m' # No Color
89

910
# Print banner
1011
echo -e "${GREEN}"
1112
echo " __ __ _ _"
12-
echo " \ \ / / | | | |"
13+
echo " \ \ / / | | | |"
1314
echo " \ \ /\ / /__ _ __| | _| | ___ _ __ ____"
1415
echo " \ \/ \/ / _ \| '__| |/ / |/ _ \ '_ \|_ /"
1516
echo " \ /\ / (_) | | | <| | __/ | | |/ /"
@@ -29,6 +30,51 @@ if [ ! -f .env ]; then
2930
fi
3031
fi
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
3379
if ! 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
3783
fi
3884

3985
# Check if Docker daemon is running
40-
echo "Running preflight checks..."
86+
echo -e "${BLUE}Running preflight checks...${NC}"
4187
if ! 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
4591
fi
4692
echo -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"
59102
else
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
63106
fi
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}"
96147
else
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"
98150
fi
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"

stop.sh

100644100755
Lines changed: 38 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,49 @@
22

33
# Colors for terminal output
44
GREEN='\033[0;32m'
5+
YELLOW='\033[1;33m'
56
RED='\033[0;31m'
7+
BLUE='\033[0;34m'
68
NC='\033[0m' # No Color
79

8-
echo -e "${RED}Stopping Worklenz Docker Environment...${NC}"
10+
# Print banner
11+
echo -e "${RED}"
12+
echo " __ __ _ _"
13+
echo " \ \ / / | | | |"
14+
echo " \ \ /\ / /__ _ __| | _| | ___ _ __ ____"
15+
echo " \ \/ \/ / _ \| '__| |/ / |/ _ \ '_ \|_ /"
16+
echo " \ /\ / (_) | | | <| | __/ | | |/ /"
17+
echo " \/ \/ \___/|_| |_|\_\_|\___|_| |_/___|"
18+
echo ""
19+
echo " W O R K L E N Z "
20+
echo -e "${NC}"
21+
echo -e "${BLUE}Stopping Worklenz Docker Environment...${NC}"
922

10-
# Check which Docker Compose command to use
23+
# Determine Docker Compose command to use
24+
DOCKER_COMPOSE_CMD=""
1125
if command -v docker compose &> /dev/null; then
12-
# Docker Compose V2
13-
docker compose down
26+
DOCKER_COMPOSE_CMD="docker compose"
27+
echo -e "${GREEN}${NC} Using Docker Compose V2"
28+
elif command -v docker-compose &> /dev/null; then
29+
DOCKER_COMPOSE_CMD="docker-compose"
30+
echo -e "${YELLOW}${NC} Using legacy Docker Compose"
1431
else
15-
# Legacy Docker Compose
16-
docker-compose down
32+
echo -e "${RED}Error: Docker Compose is not installed or not in PATH${NC}"
33+
echo "Please install Docker Compose: https://docs.docker.com/compose/install/"
34+
exit 1
1735
fi
1836

19-
echo -e "${GREEN}Worklenz services have been stopped.${NC}"
37+
# Stop the containers
38+
echo -e "${BLUE}Stopping all services...${NC}"
39+
$DOCKER_COMPOSE_CMD down
40+
41+
# Check if containers are still running
42+
if docker ps | grep -q "worklenz_"; then
43+
echo -e "${YELLOW}⚠ Some Worklenz containers are still running. Forcing stop...${NC}"
44+
docker stop $(docker ps -q --filter "name=worklenz_")
45+
echo -e "${GREEN}${NC} Forced stop completed."
46+
else
47+
echo -e "${GREEN}${NC} All Worklenz services have been stopped successfully."
48+
fi
49+
50+
echo -e "\n${BLUE}To start Worklenz again, run:${NC} ./start.sh"

0 commit comments

Comments
 (0)