-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdeploy.sh
More file actions
executable file
·193 lines (163 loc) · 5.42 KB
/
Copy pathdeploy.sh
File metadata and controls
executable file
·193 lines (163 loc) · 5.42 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
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
#!/bin/bash
# ========================================
# A2A-ACP Push Notifications Deployment Script
# ========================================
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 check if command exists
command_exists() {
command -v "$1" >/dev/null 2>&1
}
# Check dependencies
check_dependencies() {
print_status "Checking dependencies..."
if ! command_exists curl; then
print_error "curl is required but not installed."
exit 1
fi
if ! command_exists docker; then
print_warning "Docker not found. Installing Docker..."
# Install Docker (basic installation for Linux)
if command_exists apt-get; then
curl -fsSL https://get.docker.com -o get-docker.sh
sudo sh get-docker.sh
sudo usermod -aG docker $USER
rm get-docker.sh
print_success "Docker installed successfully"
else
print_error "Please install Docker manually: https://docs.docker.com/get-docker/"
exit 1
fi
else
print_success "Dependencies check passed"
fi
}
# Create necessary directories
create_directories() {
print_status "Creating necessary directories..."
mkdir -p data
mkdir -p logs
print_success "Directories created"
}
# Generate .env file if it doesn't exist
setup_environment() {
if [ ! -f .env ]; then
print_status "Creating .env file from template..."
cp .env.example .env
# Generate a secure random token
if command_exists openssl; then
A2A_TOKEN=$(openssl rand -hex 32)
sed -i "s/A2A_AUTH_TOKEN=.*/A2A_AUTH_TOKEN=\"$A2A_TOKEN\"/" .env
fi
print_warning ".env file created. Please review and customize the settings."
print_warning "Your A2A_AUTH_TOKEN has been generated automatically."
else
print_success ".env file already exists"
fi
}
# Build and deploy with Docker Compose
deploy_with_docker() {
print_status "Building and deploying with Docker Compose..."
# Stop existing containers
docker-compose down || true
# Build and start services
docker-compose up --build -d
print_success "Application deployed successfully!"
print_status "Application is running at: http://localhost:8000"
print_status "Health check available at: http://localhost:8000/health"
print_status "Push notification metrics at: http://localhost:8000/metrics/push-notifications"
print_status "System metrics at: http://localhost:8000/metrics/system"
}
# Check if application is healthy
check_health() {
print_status "Checking application health..."
# Wait for application to start
print_status "Waiting for application to be ready..."
sleep 10
# Check health endpoint
if curl -f http://localhost:8000/health >/dev/null 2>&1; then
print_success "Application is healthy!"
# Display service information
echo
echo "=========================================="
echo "A2A-ACP Push Notifications is running!"
echo "=========================================="
echo "API Endpoints:"
echo " - Main API: http://localhost:8000"
echo " - Health Check: http://localhost:8000/health"
echo " - Metrics (Push): http://localhost:8000/metrics/push-notifications"
echo " - Metrics (System): http://localhost:8000/metrics/system"
echo " - WebSocket: ws://localhost:8000/streaming/websocket"
echo " - Server-Sent Events: http://localhost:8000/streaming/sse"
echo
echo "A2A Protocol Endpoints:"
echo " - JSON-RPC: http://localhost:8000/a2a/rpc"
echo " - Message Send: http://localhost:8000/a2a/message/send"
echo
echo "Logs are available in: ./logs/"
echo "Data is stored in: ./data/"
echo
echo "To stop the application: docker-compose down"
echo "To view logs: docker-compose logs -f"
echo "=========================================="
else
print_error "Application health check failed!"
print_error "Check the logs with: docker-compose logs"
exit 1
fi
}
# Main deployment flow
main() {
echo "=========================================="
echo "A2A-ACP Push Notifications Deployment"
echo "=========================================="
echo
check_dependencies
create_directories
setup_environment
deploy_with_docker
check_health
print_success "Deployment completed successfully!"
}
# Handle script arguments
case "${1:-}" in
"stop")
print_status "Stopping application..."
docker-compose down
print_success "Application stopped"
;;
"logs")
print_status "Showing application logs..."
docker-compose logs -f
;;
"restart")
print_status "Restarting application..."
docker-compose restart
print_success "Application restarted"
;;
"status")
print_status "Checking application status..."
docker-compose ps
;;
*)
main
;;
esac