#!/bin/bash set -e datetime_prefix() { date "+[%Y-%m-%d %H:%M:%S]" } echo "$(datetime_prefix) Starting Whisper Transcriptor in API mode with nginx..." # Check if image exists if ! docker image inspect transcriptor-apimcp:latest &> /dev/null; then echo "$(datetime_prefix) Image not found. Building first..." ./docker-build.sh fi # Stop and remove existing container if running if docker ps -a --format '{{.Names}}' | grep -q '^transcriptor-api$'; then echo "$(datetime_prefix) Stopping existing container..." docker stop transcriptor-api || true docker rm transcriptor-api || true fi # Run the container in API mode docker run -d \ --name transcriptor-api \ --gpus all \ -p 33767:80 \ -e SERVER_MODE=api \ -e API_HOST=127.0.0.1 \ -e API_PORT=33767 \ -e CUDA_VISIBLE_DEVICES=0 \ -e TRANSCRIPTION_MODEL=large-v3 \ -e TRANSCRIPTION_DEVICE=auto \ -e TRANSCRIPTION_COMPUTE_TYPE=auto \ -e JOB_QUEUE_MAX_SIZE=5 \ -v "$(pwd)/models:/models" \ -v "$(pwd)/outputs:/outputs" \ -v "$(pwd)/logs:/logs" \ --restart unless-stopped \ transcriptor-apimcp:latest echo "$(datetime_prefix) Container started!" echo "" echo "API Server running at: http://localhost:33767" echo "" echo "Useful commands:" echo " Check logs: docker logs -f transcriptor-api" echo " Check status: docker ps | grep transcriptor-api" echo " Test health: curl http://localhost:33767/health" echo " Test GPU: curl http://localhost:33767/health/gpu" echo " Stop container: docker stop transcriptor-api" echo " Restart: docker restart transcriptor-api" echo "" echo "$(datetime_prefix) Waiting for service to start..." sleep 5 # Test health endpoint if curl -s http://localhost:33767/health > /dev/null 2>&1; then echo "$(datetime_prefix) ✓ Service is healthy!" else echo "$(datetime_prefix) ⚠ Service not responding yet. Check logs with: docker logs transcriptor-api" fi