feat: Implement configurable pump control preprocessing logic #5
|
|
@ -0,0 +1,73 @@
|
|||
#!/bin/bash
|
||||
|
||||
# Calejo Control Adapter - On-premises Deployment Script
|
||||
# For local development and testing deployments
|
||||
|
||||
set -e
|
||||
|
||||
echo "🚀 Calejo Control Adapter - On-premises Deployment"
|
||||
echo "=================================================="
|
||||
echo ""
|
||||
|
||||
# Check if Docker is available
|
||||
if ! command -v docker &> /dev/null; then
|
||||
echo "❌ Docker is not installed. Please install Docker first."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Check if Docker Compose is available
|
||||
if ! command -v docker-compose &> /dev/null; then
|
||||
echo "❌ Docker Compose is not installed. Please install Docker Compose first."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "✅ Docker and Docker Compose are available"
|
||||
|
||||
# Build and start services
|
||||
echo ""
|
||||
echo "🔨 Building and starting services..."
|
||||
|
||||
# Stop existing services if running
|
||||
echo "Stopping existing services..."
|
||||
docker-compose down 2>/dev/null || true
|
||||
|
||||
# Build services
|
||||
echo "Building Docker images..."
|
||||
docker-compose build --no-cache
|
||||
|
||||
# Start services
|
||||
echo "Starting services..."
|
||||
docker-compose up -d
|
||||
|
||||
# Wait for services to be ready
|
||||
echo ""
|
||||
echo "⏳ Waiting for services to start..."
|
||||
for i in {1..30}; do
|
||||
if curl -s http://localhost:8080/health > /dev/null; then
|
||||
echo "✅ Services started successfully"
|
||||
break
|
||||
fi
|
||||
echo " Waiting... (attempt $i/30)"
|
||||
sleep 2
|
||||
|
||||
if [[ $i -eq 30 ]]; then
|
||||
echo "❌ Services failed to start within 60 seconds"
|
||||
docker-compose logs
|
||||
exit 1
|
||||
fi
|
||||
done
|
||||
|
||||
echo ""
|
||||
echo "🎉 Deployment completed successfully!"
|
||||
echo ""
|
||||
echo "🔗 Access URLs:"
|
||||
echo " Dashboard: http://localhost:8080/dashboard"
|
||||
echo " REST API: http://localhost:8080"
|
||||
echo " Health Check: http://localhost:8080/health"
|
||||
echo ""
|
||||
echo "🔧 Management Commands:"
|
||||
echo " View logs: docker-compose logs -f"
|
||||
echo " Stop services: docker-compose down"
|
||||
echo " Restart: docker-compose restart"
|
||||
echo ""
|
||||
echo "=================================================="
|
||||
|
|
@ -319,7 +319,20 @@ setup_remote_configuration() {
|
|||
|
||||
# Set permissions on scripts
|
||||
execute_remote "chmod +x $TARGET_DIR/scripts/*.sh" "Setting script permissions"
|
||||
execute_remote "chmod +x $TARGET_DIR/deploy-onprem.sh" "Setting deployment script permissions"
|
||||
|
||||
# Set permissions on deployment script if it exists
|
||||
if [[ "$DRY_RUN" == "true" ]]; then
|
||||
# In dry-run mode, just show what would happen
|
||||
execute_remote "cd $TARGET_DIR && test -f deploy-onprem.sh" "Checking for deploy-onprem.sh"
|
||||
execute_remote "chmod +x $TARGET_DIR/deploy-onprem.sh" "Setting deployment script permissions"
|
||||
else
|
||||
# In actual deployment mode, check if file exists first
|
||||
if execute_remote "cd $TARGET_DIR && test -f deploy-onprem.sh" "Checking for deploy-onprem.sh" 2>/dev/null; then
|
||||
execute_remote "chmod +x $TARGET_DIR/deploy-onprem.sh" "Setting deployment script permissions"
|
||||
else
|
||||
print_warning "deploy-onprem.sh not found, skipping permissions"
|
||||
fi
|
||||
fi
|
||||
|
||||
print_success "Remote configuration setup completed"
|
||||
}
|
||||
|
|
@ -328,16 +341,36 @@ setup_remote_configuration() {
|
|||
build_and_start_services() {
|
||||
print_status "Building and starting services..."
|
||||
|
||||
# Build services
|
||||
execute_remote "cd $TARGET_DIR && sudo docker-compose build" "Building Docker images"
|
||||
# Stop existing services first to ensure clean rebuild
|
||||
print_status "Stopping existing services..."
|
||||
execute_remote "cd $TARGET_DIR && sudo docker-compose down" "Stopping existing services" || {
|
||||
print_warning "Failed to stop some services, continuing with build..."
|
||||
}
|
||||
|
||||
# Build services with no-cache to ensure fresh build
|
||||
print_status "Building Docker images (with --no-cache to ensure fresh build)..."
|
||||
execute_remote "cd $TARGET_DIR && sudo docker-compose build --no-cache" "Building Docker images" || {
|
||||
print_error "Docker build failed"
|
||||
return 1
|
||||
}
|
||||
|
||||
# Start services - use environment-specific compose file if available
|
||||
print_status "Starting services..."
|
||||
if [[ "$ENVIRONMENT" == "production" ]] && execute_remote "cd $TARGET_DIR && test -f docker-compose.production.yml" "Checking for production compose file" 2>/dev/null; then
|
||||
execute_remote "cd $TARGET_DIR && sudo docker-compose -f docker-compose.production.yml up -d" "Starting services with production configuration"
|
||||
execute_remote "cd $TARGET_DIR && sudo docker-compose -f docker-compose.production.yml up -d" "Starting services with production configuration" || {
|
||||
print_error "Failed to start services with production configuration"
|
||||
return 1
|
||||
}
|
||||
elif [[ "$ENVIRONMENT" == "test" ]] && execute_remote "cd $TARGET_DIR && test -f docker-compose.test.yml" "Checking for test compose file" 2>/dev/null; then
|
||||
execute_remote "cd $TARGET_DIR && sudo docker-compose -f docker-compose.test.yml up -d" "Starting services with test configuration"
|
||||
execute_remote "cd $TARGET_DIR && sudo docker-compose -f docker-compose.test.yml up -d" "Starting services with test configuration" || {
|
||||
print_error "Failed to start services with test configuration"
|
||||
return 1
|
||||
}
|
||||
else
|
||||
execute_remote "cd $TARGET_DIR && sudo docker-compose up -d" "Starting services"
|
||||
execute_remote "cd $TARGET_DIR && sudo docker-compose up -d" "Starting services" || {
|
||||
print_error "Failed to start services"
|
||||
return 1
|
||||
}
|
||||
fi
|
||||
|
||||
# Wait for services to be ready
|
||||
|
|
|
|||
|
|
@ -0,0 +1,45 @@
|
|||
#!/bin/bash
|
||||
|
||||
# Calejo Control Adapter - Deployment Validation Script
|
||||
# Validates that the deployment was successful
|
||||
|
||||
set -e
|
||||
|
||||
echo "🔍 Validating deployment..."
|
||||
|
||||
# Check if services are running
|
||||
if ! docker-compose ps | grep -q "Up"; then
|
||||
echo "❌ Some services are not running"
|
||||
docker-compose ps
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "✅ All services are running"
|
||||
|
||||
# Test health endpoint
|
||||
if ! curl -s -f http://localhost:8080/health > /dev/null; then
|
||||
echo "❌ Health endpoint is not accessible"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "✅ Health endpoint is accessible"
|
||||
|
||||
# Test dashboard endpoint
|
||||
if ! curl -s -f http://localhost:8080/dashboard > /dev/null; then
|
||||
echo "❌ Dashboard endpoint is not accessible"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "✅ Dashboard endpoint is accessible"
|
||||
|
||||
# Test API endpoint
|
||||
if ! curl -s -f http://localhost:8080/api/v1/status > /dev/null; then
|
||||
echo "❌ API endpoint is not accessible"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "✅ API endpoint is accessible"
|
||||
|
||||
echo ""
|
||||
echo "🎉 Deployment validation passed!"
|
||||
exit 0
|
||||
Loading…
Reference in New Issue