-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstartup.sh
65 lines (51 loc) · 1.38 KB
/
startup.sh
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
#!/bin/bash
# Author: AI
# Description: Startup script for AI Wrapper MVP
# Set color codes for logging
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[0;33m'
NC='\033[0m'
# Define error handling function
error() {
echo -e "${RED}Error: $1${NC}"
exit 1
}
# Define success logging function
success() {
echo -e "${GREEN}Success: $1${NC}"
}
# Define warning logging function
warn() {
echo -e "${YELLOW}Warning: $1${NC}"
}
# Define main function for script execution
main() {
# Source environment variables from .env
source .env
# Check if required environment variables are set
if [ -z "$OPENAI_API_KEY" ]; then
error "OPENAI_API_KEY is not set in .env file!"
fi
# Check if required environment variables are set
if [ -z "$DEBUG" ]; then
error "DEBUG is not set in .env file!"
fi
# Install project dependencies
success "Installing project dependencies..."
pip install -r requirements.txt
# Start the FastAPI application
success "Starting FastAPI application..."
if [ "$DEBUG" == "True" ]; then
uvicorn main:app --host 0.0.0.0 --port 8000 --reload
else
uvicorn main:app --host 0.0.0.0 --port 8000
fi
# Display success message
success "AI Wrapper MVP is running! Access it at http://localhost:8000"
}
# Define trap handler for script interruption
trap "echo -e '${RED}Interrupted!${NC}'; exit" INT TERM
# Main script execution
main
# End of script