Running Agents
Running Agents
Section titled “Running Agents”Once registered, your agent needs to be running to accept and execute builds. This guide covers starting, stopping, and managing agents.
Starting the Agent
Section titled “Starting the Agent”Foreground Mode
Section titled “Foreground Mode”Run the agent in the current terminal session:
flightstack agent startOutput:
FlightStack Build Agent────────────────────────────────────────────────────Agent: My-MacBook-ProAPI: https://api.flightstack.devID: a1b2c3d4-e5f6-7890-abcd-ef1234567890
✓ Agent is online
Waiting for builds... (Ctrl+C to stop)The agent will:
- Send heartbeats every 60 seconds
- Poll for new jobs every 10 seconds
- Execute any assigned builds
- Report status back to FlightStack
Multi-URL Failover
Section titled “Multi-URL Failover”Specify multiple API URLs for failover. The agent tries each URL in order and connects to the first available:
flightstack-agent start \ --api-url http://localhost:5000 \ --api-url https://api.flightstack.voostack.comThe agent will:
- Try URLs in order (first takes priority)
- Connect to the first successful API
- Automatically reconnect to higher-priority URLs when available
Auto-Reconnection
Section titled “Auto-Reconnection”When connected to a fallback URL, the agent periodically tries to reconnect to higher-priority URLs:
# Check for higher-priority URLs every 60 seconds (default: 30)flightstack-agent start \ --api-url http://localhost:5000 \ --api-url https://api.flightstack.voostack.com \ --reconnect-interval 60This is useful for local development - the agent connects to your local API when running, but falls back to production if local is unavailable.
Using Profiles
Section titled “Using Profiles”Start the agent with a specific configuration profile:
# Use config.dev.json instead of config.jsonflightstack-agent start --profile devOr set via environment variable:
export FLIGHTSTACK_PROFILE=devflightstack-agent startBackground Mode (Daemon)
Section titled “Background Mode (Daemon)”Run the agent in the background:
flightstack agent start --daemonOutput:
Starting agent in background...
✓ Agent started in background
PID: 12345Log: /Users/you/.flightstack/agent.log
To stop: flightstack agent stopTo view status: flightstack agent statusThe agent runs detached from your terminal session.
Stopping the Agent
Section titled “Stopping the Agent”Stop a running agent:
flightstack agent stopOutput:
Stopping agent (PID: 12345)...✓ Agent stoppedChecking Agent Status
Section titled “Checking Agent Status”View the local agent status:
flightstack agent statusOutput when running:
Local Agent Status────────────────────────────────────────────────────Name: My-MacBook-ProID: a1b2c3d4-e5f6-7890-abcd-ef1234567890API: https://api.flightstack.devPlatform: macOSScope: Public (available to all organizations)
Process: Running (PID: 12345)
To stop: flightstack agent stopOutput when stopped:
Local Agent Status────────────────────────────────────────────────────Name: My-MacBook-ProID: a1b2c3d4-e5f6-7890-abcd-ef1234567890API: https://api.flightstack.devPlatform: macOSScope: Public (available to all organizations)
Process: Stopped
To start: flightstack agent startTo start in background: flightstack agent start --daemonViewing Agent Logs
Section titled “Viewing Agent Logs”When running in daemon mode, logs are written to:
# View logstail -f ~/.flightstack/agent.log
# View errorstail -f ~/.flightstack/agent.error.log# View logsGet-Content "$env:USERPROFILE\.flightstack\agent.log" -WaitExample log output:
[14:32:15] FlightStack Build Agent[14:32:15] Agent: My-MacBook-Pro[14:32:15] ✓ Connected[14:32:15] ✓ Agent is online[14:32:15] Waiting for builds...[14:35:22] New build job received[14:35:22] Repository: my-app[14:35:22] Branch: main[14:35:22] Commit: abc1234[14:35:22] Platform: iOSBuild Execution
Section titled “Build Execution”When a build is assigned, the agent:
-
Receives job details
- Repository URL
- Branch and commit
- Build steps and configuration
-
Prepares workspace
- Creates a temporary directory
- Clones the repository
- Checks out the specified commit
-
Executes build steps
- Runs each step in order
- Streams logs to FlightStack
- Uploads artifacts as they’re created
-
Reports completion
- Final status (success/failure)
- Build duration
- Any error messages
-
Cleans up
- Removes temporary files
- Returns to idle state
Resource Management
Section titled “Resource Management”Disk Space
Section titled “Disk Space”The agent monitors disk space and will stop accepting builds if free space falls below 10 GB:
Agent paused: Insufficient disk space: 8.5GB available, 10GB requiredFree up space or configure a different workspace to resume.
Concurrent Builds
Section titled “Concurrent Builds”By default, agents run one build at a time. This ensures:
- Maximum resources for each build
- No interference between builds
- Predictable build times
Memory & CPU
Section titled “Memory & CPU”Builds use your machine’s full resources. For large projects:
- Close unnecessary applications
- Consider dedicated build machines
- Monitor memory during builds
Troubleshooting
Section titled “Troubleshooting”Agent Won’t Start
Section titled “Agent Won’t Start”Already running:
Agent is already running (PID: 12345)Use: flightstack agent stopStop the existing agent first, then start again.
Not registered:
Agent not registered. Run: flightstack agent registerRegister the agent before starting.
Connection Failed
Section titled “Connection Failed”Connection failedError: Connection timed out
Please check: 1. API is running at https://api.flightstack.dev 2. Agent token is valid 3. Agent is registered in the systemPossible causes:
- Network connectivity issues
- Firewall blocking outbound HTTPS
- Invalid or expired token
Try:
# Test connectivitycurl https://api.flightstack.dev/health
# Re-register if token is invalidflightstack agent registerHeartbeat Failures
Section titled “Heartbeat Failures”Heartbeat failed: Connection refusedThe agent will retry automatically. If persistent:
- Check network connectivity
- Verify the API is accessible
- Check for proxy/firewall issues
Build Failures
Section titled “Build Failures”If builds fail unexpectedly:
- Check the build logs in FlightStack app
- Verify Flutter is working:
flutter doctor - Ensure Xcode is configured (iOS):
xcode-select -p - Check the agent logs for errors
Next Steps
Section titled “Next Steps”- Auto-Start on Boot - Configure agent to start automatically
- Agent Capabilities - Configure what the agent can build
- Troubleshooting - Solve common issues