Skip to content

Add gh devlake stop command #128

@ewega

Description

@ewega

Summary

Add a gh devlake stop command that gracefully stops DevLake services without destroying containers, volumes, or state. This is the counterpart to gh devlake start (#127) and distinct from gh devlake cleanup which tears everything down permanently.

Mental model for users:

  • start — bring services up (safe, idempotent)
  • stop — pause services (safe, non-destructive, data preserved)
  • cleanup — permanent teardown (removes containers, volumes, files)

Proposed Solution

Local deployments (Docker Compose)

  1. Auto-detect deployment from state file (.devlake-local.json) or docker-compose.yml in cwd
  2. Run docker compose stop (graceful stop — preserves containers and volumes for quick restart)
  3. Print confirmation

Azure deployments (Container Instances)

  1. Read container names + resource group from .devlake-azure.json
  2. Check Azure CLI login
  3. Run az container stop for each container
  4. Print confirmation

Key design decisions

  • Uses docker compose stop (not docker compose down) — preserves containers and volumes for fast restart via start
  • State file is NOT modified — Docker/Azure is the source of truth for runtime state
  • No confirmation prompt needed (unlike cleanup) since the operation is non-destructive

Prerequisites: ComposeStop in docker package

Add ComposeStop(dir string) error to internal/docker/build.go:

func ComposeStop(dir string) error {
    cmd := execCommand("docker", "compose", "stop")
    cmd.Dir = dir
    if out, err := cmd.CombinedOutput(); err != nil {
        return fmt.Errorf("docker compose stop failed: %s\n%s", err, string(out))
    }
    return nil
}

Flags

Flag Default Description
--service <name> (all) Stop only a specific service (e.g., --service grafana)

Scope of Changes

File Change
internal/docker/build.go Add ComposeStop() function
internal/docker/docker_test.go Add test for ComposeStop (mock pattern exists)
cmd/stop.go New command implementation
cmd/deploy.go Register stop in operate command group
docs/stop.md New documentation
docs/day-2.md Add stop to operations list
README.md Add to command reference table

Acceptance Criteria

  • gh devlake stop gracefully stops all local services
  • gh devlake stop --service grafana stops only Grafana
  • gh devlake stop works for Azure deployments (reads state file)
  • Containers and volumes preserved after stop (verifiable with docker ps -a)
  • gh devlake start brings everything back up cleanly after stop
  • Error message guides user when no state file or docker-compose.yml found

Dependencies

References

  • internal/docker/build.goComposeDown() and ComposeUp() patterns
  • cmd/cleanup.gorunLocalCleanup() uses ComposeDown (destructive counterpart)

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions