-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdev.sh
More file actions
126 lines (98 loc) · 2.94 KB
/
dev.sh
File metadata and controls
126 lines (98 loc) · 2.94 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
#!/bin/bash
# Development run script for Leaf Classifier Application
# This script starts all three services: classifier, frontend, and backend
set -e # Exit on any error
# Colors for output
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
BLUE='\033[0;34m'
NC='\033[0m' # No Color
# Function to print colored output
print_status() {
echo -e "${BLUE}[INFO]${NC} $1"
}
print_success() {
echo -e "${GREEN}[SUCCESS]${NC} $1"
}
print_warning() {
echo -e "${YELLOW}[WARNING]${NC} $1"
}
print_error() {
echo -e "${RED}[ERROR]${NC} $1"
}
# Function to cleanup background processes on exit
cleanup() {
print_status "Shutting down services..."
# Kill all background processes
if [ ! -z "$CLASSIFIER_PID" ]; then
kill $CLASSIFIER_PID 2>/dev/null || true
print_status "Classifier service stopped"
fi
if [ ! -z "$FRONTEND_PID" ]; then
kill $FRONTEND_PID 2>/dev/null || true
print_status "Frontend service stopped"
fi
if [ ! -z "$BACKEND_PID" ]; then
kill $BACKEND_PID 2>/dev/null || true
print_status "Backend service stopped"
fi
print_success "All services stopped"
exit 0
}
# Set up signal handlers for cleanup
trap cleanup SIGINT SIGTERM
# Check if required directories exist
if [ ! -d "classifier" ]; then
print_error "Classifier directory not found"
exit 1
fi
if [ ! -d "frontend" ]; then
print_error "Frontend directory not found"
exit 1
fi
if [ ! -d "backend" ]; then
print_error "Backend directory not found"
exit 1
fi
print_status "Starting Leaf Classifier Development Environment..."
# Start Classifier Service (Flask)
print_status "Starting Classifier Service..."
cd classifier
# Check if virtual environment exists
if [ ! -d "env" ]; then
print_error "Virtual environment not found in classifier directory"
print_warning "Please create a virtual environment first:"
print_warning "cd classifier && python3 -m venv env && source env/bin/activate && pip install -r requirements.txt"
exit 1
fi
# Activate virtual environment and start Flask app
source env/bin/activate
python3 main.py &
CLASSIFIER_PID=$!
cd ..
print_success "Classifier service started (PID: $CLASSIFIER_PID)"
# Start Backend Service
print_status "Starting Backend Service..."
cd backend
bun run dev &
BACKEND_PID=$!
cd ..
print_success "Backend service started (PID: $BACKEND_PID)"
# Start Frontend Service
print_status "Starting Frontend Service..."
cd frontend
bun run dev &
FRONTEND_PID=$!
cd ..
print_success "Frontend service started (PID: $FRONTEND_PID)"
print_success "All services started successfully!"
echo ""
print_status "Services are running on:"
print_status " - Classifier: http://localhost:8000"
print_status " - Backend: Check the backend output for the port"
print_status " - Frontend: Check the frontend output for the port"
echo ""
print_status "Press Ctrl+C to stop all services"
# Wait for all background processes
wait