Skip to content

Stop containers after each task to reduce RAM usage#81

Open
actflower wants to merge 6 commits intomainfrom
feature/stop-container-after-task
Open

Stop containers after each task to reduce RAM usage#81
actflower wants to merge 6 commits intomainfrom
feature/stop-container-after-task

Conversation

@actflower
Copy link
Collaborator

Summary

  • Implements the approach suggested in issue Limit number of containers #79: stop containers immediately after each task completes, then start them again for the next task
  • This ensures only one running container per dev name (queue) at any time, significantly reducing RAM usage when multiple repos are in play
  • Adds STOP_CONTAINER_AFTER_TASK config option (default: true)

Changes

  • Add STOP_CONTAINER_AFTER_TASK config option in config.py
  • Modify container pool to stop containers after task completion when enabled
  • Add stop_container_after_task to status endpoint cleanup_settings
  • Update documentation in CLAUDE.md
  • Add comprehensive tests (6 new tests) for the new functionality

Behavior

New default behavior (stop_container_after_task=true):

  • Container is started when a task begins
  • Container is stopped and cleaned up immediately after task completes
  • Next task on same queue starts a fresh container
  • Only one running container per dev name at any time

Legacy behavior can be restored by setting STOP_CONTAINER_AFTER_TASK=false, which keeps containers running with idle timeout-based cleanup.

Test plan

  • All 87 webhook tests pass
  • Test in production environment with multiple repos

Closes #79

This implements the approach suggested in issue #79: stop containers
immediately after each task completes, then start them again for the
next task. This ensures only one running container per dev name (queue)
at any time, significantly reducing RAM usage when multiple repos are
in play.

Changes:
- Add STOP_CONTAINER_AFTER_TASK config option (default: true)
- Modify container pool to stop containers after task completion
- Add stop_container_after_task to status endpoint cleanup_settings
- Update documentation in CLAUDE.md
- Add comprehensive tests for the new functionality

The new default behavior (stop_container_after_task=true) means:
- Container is started when a task begins
- Container is stopped and cleaned up immediately after task completes
- Next task on same queue starts a fresh container
- Only one running container per dev name at any time

Legacy behavior can be restored by setting STOP_CONTAINER_AFTER_TASK=false,
which keeps containers running with idle timeout-based cleanup.

Closes #79
actflower and others added 5 commits January 24, 2026 12:11
This allows the stop-after-task workflow to preserve workspaces for
faster container restarts. When remove_workspace=False, containers are
stopped but workspaces are kept on disk for reuse.

Adds tests for the new cleanup behavior.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Limit number of containers

2 participants