Skip to content

Fix service restart race condition in bot deployment #71

@BenGWeeks

Description

@BenGWeeks

Overview

There's a potential race condition when restarting the PennieBot service during deployment.

Current State

  • Deploy workflow restarts service with Restart-Service PennieBot
  • Health check runs immediately after
  • No wait time for service to fully initialize

Symptoms

  • Intermittent health check failures after deployment
  • "Service unavailable" errors immediately after restart

Recommended Solution

  1. Add retry logic to health checks
  2. Wait for service status to become "Running"
  3. Add exponential backoff for health endpoint checks

Example

# Wait for service to start
$maxRetries = 30
$retryCount = 0
do {
    Start-Sleep -Seconds 2
    $status = (Get-Service PennieBot).Status
    $retryCount++
} while ($status -ne 'Running' -and $retryCount -lt $maxRetries)

# Then check health endpoint

Acceptance Criteria

  • Health checks wait for service initialization
  • Deployment doesn't fail due to timing issues
  • Reasonable timeout (e.g., 60 seconds max)

🤖 Generated with Claude Code

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingenhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions