Merge pull request #79 from chamikaJ/react-version

Update README.md and scripts for improved setup and service management
This commit is contained in:
Chamika J
2025-04-21 20:56:40 +05:30
committed by GitHub
3 changed files with 147 additions and 64 deletions

View File

@@ -62,7 +62,7 @@ These instructions will help you set up and run the Worklenz project on your loc
1. Clone the repository
```bash
git clone https://github.com/yourusername/worklenz.git
git clone https://github.com/Worklenz/worklenz.git
cd worklenz
```
@@ -124,7 +124,7 @@ The project includes a fully configured Docker setup with:
1. Clone the repository:
```bash
git clone https://github.com/yourusername/worklenz.git
git clone https://github.com/Worklenz/worklenz.git
cd worklenz
```
@@ -272,8 +272,8 @@ The project includes a fully configured Docker setup with:
1. Clone the repository:
```bash
git clone https://github.com/yourusername/worklenz-react-v1.git
cd worklenz-react-v1
git clone https://github.com/Worklenz/worklenz.git
cd worklenz
```
2. Start the Docker containers (choose one option):

158
start.sh Normal file → Executable file
View File

@@ -4,12 +4,13 @@
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
RED='\033[0;31m'
BLUE='\033[0;34m'
NC='\033[0m' # No Color
# Print banner
echo -e "${GREEN}"
echo " __ __ _ _"
echo " \ \ / / | | | |"
echo " \ \ / / | | | |"
echo " \ \ /\ / /__ _ __| | _| | ___ _ __ ____"
echo " \ \/ \/ / _ \| '__| |/ / |/ _ \ '_ \|_ /"
echo " \ /\ / (_) | | | <| | __/ | | |/ /"
@@ -29,6 +30,51 @@ if [ ! -f .env ]; then
fi
fi
# Function to check if a service is running
check_service() {
local service_name=$1
local container_name=$2
local url=$3
local max_attempts=30
local attempt=1
echo -e "${BLUE}Checking ${service_name} service...${NC}"
# First check if the container is running
while [ $attempt -le $max_attempts ]; do
if docker ps | grep -q "${container_name}"; then
# Container is running
if [ -z "$url" ]; then
# No URL to check, assume service is up
echo -e "${GREEN}${NC} ${service_name} is running"
return 0
else
# Check if service endpoint is responding
if curl -s -f -o /dev/null "$url"; then
echo -e "${GREEN}${NC} ${service_name} is running and responding at ${url}"
return 0
else
if [ $attempt -eq $max_attempts ]; then
echo -e "${YELLOW}${NC} ${service_name} container is running but not responding at ${url}"
return 1
fi
fi
fi
else
if [ $attempt -eq $max_attempts ]; then
echo -e "${RED}${NC} ${service_name} failed to start"
return 1
fi
fi
echo -n "."
attempt=$((attempt+1))
sleep 1
done
return 1
}
# Check if Docker is installed
if ! command -v docker &> /dev/null; then
echo -e "${RED}Error: Docker is not installed or not in PATH${NC}"
@@ -37,7 +83,7 @@ if ! command -v docker &> /dev/null; then
fi
# Check if Docker daemon is running
echo "Running preflight checks..."
echo -e "${BLUE}Running preflight checks...${NC}"
if ! docker info &> /dev/null; then
echo -e "${RED}Error: Docker daemon is not running${NC}"
echo "Please start Docker and try again"
@@ -45,58 +91,64 @@ if ! docker info &> /dev/null; then
fi
echo -e "${GREEN}${NC} Docker is running"
# Check if Docker Compose is installed
if ! command -v docker compose &> /dev/null; then
echo "Warning: Docker Compose V2 not found, trying docker-compose command..."
if ! command -v docker-compose &> /dev/null; then
echo "Error: Docker Compose is not installed or not in PATH"
echo "Please install Docker Compose: https://docs.docker.com/compose/install/"
exit 1
# Determine Docker Compose command to use
DOCKER_COMPOSE_CMD=""
if command -v docker compose &> /dev/null; then
DOCKER_COMPOSE_CMD="docker compose"
echo -e "${GREEN}${NC} Using Docker Compose V2"
elif command -v docker-compose &> /dev/null; then
DOCKER_COMPOSE_CMD="docker-compose"
echo -e "${YELLOW}${NC} Using legacy Docker Compose"
else
echo -e "${RED}Error: Docker Compose is not installed or not in PATH${NC}"
echo "Please install Docker Compose: https://docs.docker.com/compose/install/"
exit 1
fi
# Check if any of the ports are already in use
ports=(3000 5000 9000 9001 5432)
for port in "${ports[@]}"; do
if lsof -i:"$port" > /dev/null 2>&1; then
echo -e "${YELLOW}⚠ Warning: Port $port is already in use. This may cause conflicts.${NC}"
fi
# Use docker-compose command instead
docker-compose down
docker-compose up -d
done
# Start the containers
echo -e "${BLUE}Starting Worklenz services...${NC}"
$DOCKER_COMPOSE_CMD down
$DOCKER_COMPOSE_CMD up -d
# Wait for services to fully initialize
echo -e "${BLUE}Waiting for services to initialize...${NC}"
echo "This may take a minute or two depending on your system..."
# Check each service
check_service "Database" "worklenz_db" ""
DB_STATUS=$?
check_service "MinIO" "worklenz_minio" "http://localhost:9000/minio/health/live"
MINIO_STATUS=$?
check_service "Backend" "worklenz_backend" "http://localhost:3000/api/health"
BACKEND_STATUS=$?
check_service "Frontend" "worklenz_frontend" "http://localhost:5000"
FRONTEND_STATUS=$?
# Display service URLs
echo -e "\n${BLUE}Service URLs:${NC}"
[ $FRONTEND_STATUS -eq 0 ] && echo " • Frontend: http://localhost:5000"
[ $BACKEND_STATUS -eq 0 ] && echo " • Backend API: http://localhost:3000"
[ $MINIO_STATUS -eq 0 ] && echo " • MinIO Console: http://localhost:9001 (login: minioadmin/minioadmin)"
# Check if all services are up
if [ $DB_STATUS -eq 0 ] && [ $MINIO_STATUS -eq 0 ] && [ $BACKEND_STATUS -eq 0 ] && [ $FRONTEND_STATUS -eq 0 ]; then
echo -e "\n${GREEN}✅ All Worklenz services are running successfully!${NC}"
else
# Use Docker Compose V2
docker compose down
docker compose up -d
echo -e "\n${YELLOW}⚠ Some services may not be running properly. Check the logs for more details:${NC}"
echo " $DOCKER_COMPOSE_CMD logs"
fi
# Wait for services to be ready
echo "Waiting for services to start..."
sleep 5
# Check if services are running
if docker ps | grep -q "worklenz_frontend"; then
echo -e "${GREEN}${NC} Frontend is running"
FRONTEND_URL="http://localhost:5000"
echo " Frontend URL: $FRONTEND_URL"
else
echo "✗ Frontend service failed to start"
fi
if docker ps | grep -q "worklenz_backend"; then
echo -e "${GREEN}${NC} Backend is running"
BACKEND_URL="http://localhost:3000"
echo " Backend URL: $BACKEND_URL"
else
echo "✗ Backend service failed to start"
fi
if docker ps | grep -q "worklenz_minio"; then
echo -e "${GREEN}${NC} MinIO is running"
MINIO_URL="http://localhost:9001"
echo " MinIO Console URL: $MINIO_URL (login: minioadmin/minioadmin)"
else
echo "✗ MinIO service failed to start"
fi
if docker ps | grep -q "worklenz_db"; then
echo -e "${GREEN}${NC} Database is running"
else
echo "✗ Database service failed to start"
fi
echo -e "\n${GREEN}Worklenz is now running!${NC}"
echo "You can access the application at: http://localhost:5000"
echo "To stop the services, run: docker compose down"
echo -e "\n${BLUE}Useful commands:${NC}"
echo " • View logs: $DOCKER_COMPOSE_CMD logs -f"
echo " • Stop services: ./stop.sh"

45
stop.sh Normal file → Executable file
View File

@@ -2,18 +2,49 @@
# Colors for terminal output
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
RED='\033[0;31m'
BLUE='\033[0;34m'
NC='\033[0m' # No Color
echo -e "${RED}Stopping Worklenz Docker Environment...${NC}"
# Print banner
echo -e "${RED}"
echo " __ __ _ _"
echo " \ \ / / | | | |"
echo " \ \ /\ / /__ _ __| | _| | ___ _ __ ____"
echo " \ \/ \/ / _ \| '__| |/ / |/ _ \ '_ \|_ /"
echo " \ /\ / (_) | | | <| | __/ | | |/ /"
echo " \/ \/ \___/|_| |_|\_\_|\___|_| |_/___|"
echo ""
echo " W O R K L E N Z "
echo -e "${NC}"
echo -e "${BLUE}Stopping Worklenz Docker Environment...${NC}"
# Check which Docker Compose command to use
# Determine Docker Compose command to use
DOCKER_COMPOSE_CMD=""
if command -v docker compose &> /dev/null; then
# Docker Compose V2
docker compose down
DOCKER_COMPOSE_CMD="docker compose"
echo -e "${GREEN}${NC} Using Docker Compose V2"
elif command -v docker-compose &> /dev/null; then
DOCKER_COMPOSE_CMD="docker-compose"
echo -e "${YELLOW}${NC} Using legacy Docker Compose"
else
# Legacy Docker Compose
docker-compose down
echo -e "${RED}Error: Docker Compose is not installed or not in PATH${NC}"
echo "Please install Docker Compose: https://docs.docker.com/compose/install/"
exit 1
fi
echo -e "${GREEN}Worklenz services have been stopped.${NC}"
# Stop the containers
echo -e "${BLUE}Stopping all services...${NC}"
$DOCKER_COMPOSE_CMD down
# Check if containers are still running
if docker ps | grep -q "worklenz_"; then
echo -e "${YELLOW}⚠ Some Worklenz containers are still running. Forcing stop...${NC}"
docker stop $(docker ps -q --filter "name=worklenz_")
echo -e "${GREEN}${NC} Forced stop completed."
else
echo -e "${GREEN}${NC} All Worklenz services have been stopped successfully."
fi
echo -e "\n${BLUE}To start Worklenz again, run:${NC} ./start.sh"