-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstart_all.sh
More file actions
executable file
Β·148 lines (124 loc) Β· 3.93 KB
/
Copy pathstart_all.sh
File metadata and controls
executable file
Β·148 lines (124 loc) Β· 3.93 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
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
#!/bin/bash
# Re-Defined Blog Automation - Complete Startup Script
# This script starts everything you need: database, website, and dashboard
clear
echo "π Re-Defined Blog Automation - Complete Setup"
echo "=============================================="
echo ""
# Colors for output
RED='\033[0;31m'
GREEN='\033[0;32m'
BLUE='\033[0;34m'
YELLOW='\033[1;33m'
NC='\033[0m' # No Color
# Function to print colored output
print_status() {
echo -e "${GREEN}β
$1${NC}"
}
print_info() {
echo -e "${BLUE}βΉοΈ $1${NC}"
}
print_warning() {
echo -e "${YELLOW}β οΈ $1${NC}"
}
print_error() {
echo -e "${RED}β $1${NC}"
}
# Check if virtual environment exists
if [ ! -d "venv" ]; then
print_error "Virtual environment not found!"
echo "Please run: python -m venv venv"
exit 1
fi
# Activate virtual environment
print_info "Activating virtual environment..."
source venv/bin/activate
print_status "Virtual environment activated"
# Check if requirements are installed
print_info "Checking dependencies..."
if ! python -c "import fastapi, streamlit, sqlalchemy" 2>/dev/null; then
print_warning "Installing missing dependencies..."
pip install -r requirements.txt
print_status "Dependencies installed"
else
print_status "All dependencies are installed"
fi
# Initialize database if it doesn't exist
if [ ! -f "re_defined_blogs.db" ]; then
print_info "Initializing database..."
python src/database/init_db.py
print_status "Database initialized"
else
print_status "Database already exists"
fi
# Check if .env file exists
if [ ! -f ".env" ]; then
print_warning "Creating .env file from template..."
cp env.example .env
print_warning "Please edit .env file and add your OpenAI API key!"
echo ""
echo "To edit: nano .env"
echo "Add your OpenAI API key to OPENAI_API_KEY="
echo ""
fi
# Create logs directory if it doesn't exist
mkdir -p logs
print_status "Setup complete! Starting services..."
echo ""
# Function to kill background processes on exit
cleanup() {
print_info "Stopping all services..."
jobs -p | xargs -r kill
print_status "All services stopped"
exit 0
}
# Set trap to cleanup on script exit
trap cleanup SIGINT SIGTERM EXIT
# Start the beautiful website
print_info "Starting beautiful blog website..."
echo "π Website will be available at: http://localhost:8080"
python web_app.py &
WEBSITE_PID=$!
# Wait a moment for the website to start
sleep 3
# Start the Streamlit dashboard
print_info "Starting Streamlit dashboard..."
echo "ποΈ Dashboard will be available at: http://localhost:8501"
streamlit run dashboard.py --server.port 8501 --server.headless true &
DASHBOARD_PID=$!
# Wait for services to start
sleep 5
# Check if services are running
if kill -0 $WEBSITE_PID 2>/dev/null; then
print_status "Website is running on http://localhost:8080"
else
print_error "Website failed to start"
fi
if kill -0 $DASHBOARD_PID 2>/dev/null; then
print_status "Dashboard is running on http://localhost:8501"
else
print_error "Dashboard failed to start"
fi
echo ""
echo "π Re-Defined Blog Automation is now running!"
echo "=============================================="
echo ""
echo "π± Services Available:"
echo " π Beautiful Website: http://localhost:8080"
echo " ποΈ Admin Dashboard: http://localhost:8501"
echo " π Health Check: http://localhost:8080/api/health"
echo " π Statistics: http://localhost:8080/api/stats"
echo ""
echo "π― Quick Start:"
echo " 1. Visit http://localhost:8501 to create blog posts"
echo " 2. View them on http://localhost:8080"
echo " 3. Generate AI content using the dashboard"
echo ""
echo "π‘ Tips:"
echo " - Add your OpenAI API key to .env file for content generation"
echo " - Check logs/ directory for any errors"
echo " - Press Ctrl+C to stop all services"
echo ""
# Keep script running and wait for user to stop
print_info "Services are running... Press Ctrl+C to stop all services"
wait