---
description: Start API dev server with automatic error monitoring and cleanup
---

You need to launch the API development server. Follow these steps carefully:

1. **Kill any existing server on port 3000**:
   - First check if there's a background shell running the dev server in Claude Code and kill it using the KillShell tool
   - Then check for any process using port 3000 with `lsof -ti:3000` and kill it with `kill -9 $(lsof -ti:3000)` if found
   - This ensures a clean restart regardless of where the server was started

2. **Start the dev server in background**:
   - Navigate to the API service directory and start the server: `cd /projects/my-projects/banatie-service/apps/api-service && pnpm dev`
   - Run this command in the background using the Bash tool with `run_in_background: true`
   - Save the shell ID for monitoring

3. **Monitor the logs**:
   - Wait 3-5 seconds for the server to start
   - Use BashOutput tool to check the background process output for errors
   - Read the api-dev.log file to verify the server started successfully
   - Look for:
     - Server startup message (should show "Server running on port 3000")
     - Any error messages or stack traces
     - Database/MinIO connection status

4. **Report status**:
   - Inform the user if the server started successfully
   - Show any errors found in the logs
   - Provide the shell ID so the user can monitor it later if needed

CRITICAL: Always kill existing servers before starting a new one to avoid port conflicts.
