Skip to content

feat(git-stacks): option to only start services that were already running - #1407

Open
EmirLogas wants to merge 4 commits into
Finsys:mainfrom
EmirLogas:feat/1246-only-running-services
Open

feat(git-stacks): option to only start services that were already running#1407
EmirLogas wants to merge 4 commits into
Finsys:mainfrom
EmirLogas:feat/1246-only-running-services

Conversation

@EmirLogas

Copy link
Copy Markdown

Proposed change

A compose file can define ten services while only five are running. Today "Sync from Git" brings all ten up, and the ones that were deliberately stopped have to be stopped again by hand.

This adds an option to bring up only the services that already had a running container. Services that are stopped stay stopped.

It is exposed in two places:

  • Sync dialog – a checkbox, pre-filled from the stack's saved setting, acting as a per-run override.
  • Git stack → Deploy options – a persistent "Only start running services" toggle, which is what webhook and scheduled syncs use (they have no dialog).

Behaviour:

Stack state Result
Some services running Only those are brought up (docker compose up -d --remove-orphans <services>)
Containers exist, none running Nothing is started; the sync reports it
No containers yet (first deploy) The whole stack is deployed

A service that was running but is no longer declared in the compose file (renamed or deleted in the repo) is dropped from the list, so compose does not fail with no such service. The progress log names the services it starts and the ones it skips.

Hawser (remote agents): the compose request now carries a serviceNames field. Agents that predate this field ignore it and still bring the whole stack up, so remote environments need matching agent support before the option takes effect there.

Testing

Verified against a three-service git stack (docker/awesome-compose, nextcloud-redis-mariadb) on a local socket environment:

  • Stopped one service, synced with the option on → Limiting deploy to running services: db, redis, command ran as docker compose -p nc-test -f ... up -d --remove-orphans db redis, and the stopped service stayed exited.
  • Same sync with the option off → the stopped service came back up (existing behaviour unchanged).
  • svelte-check reports no new errors or warnings from these files.

Closes #1246

Type of change

  • Bug fix: non-breaking change which fixes an issue.
  • New feature / Enhancement: non-breaking change which adds functionality.
  • Breaking change: fix or feature that would cause existing functionality to not work as expected.
  • Other. Please explain:

…ning

Adds a per-stack deploy option plus a checkbox in the sync dialog. When
enabled, a git sync brings up only the services that had a running
container, so services stopped on purpose stay stopped instead of being
started by the sync.

- git_stacks.only_running_services column (SQLite + Postgres, migration 0011)
- deployStack resolves the running services and passes them to compose;
  services no longer declared in the compose file are dropped so compose
  does not fail with "no such service"
- a stack with containers but nothing running starts nothing; a stack with
  no containers yet still deploys everything
- webhook/scheduled syncs use the saved setting, the dialog checkbox is a
  per-run override

Closes Finsys#1246

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@CLAassistant

CLAassistant commented Aug 14, 2026

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@Caedis

Caedis commented Aug 17, 2026

Copy link
Copy Markdown

Might i suggest docker compose create for any containers that were updated but were stopped at the time?

A limited sync left stopped services untouched, so they kept the previous
definition until the next full deploy. They are now recreated with
`docker compose create` after the `up`, picking up the new config and image
while staying stopped.

- new `create` compose operation, mirroring the deploy's --build/--pull
- a fully stopped stack skips the `up` entirely but is still refreshed
- a failed create never fails the deploy: Hawser agents that predate the
  operation reject it, and the running services are already up to date
- services that never had a container are not created, only ones that exist
  and are stopped

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@EmirLogas

Copy link
Copy Markdown
Author

Yes, recreating them so they pick up the update while staying stopped makes more sense. Thanks for catching that subtle detail, @Caedis. Implemented and pushed.

main landed its own 0011 migration (pending_updates_semver), so this branch's
migration is renumbered to 0012 and its snapshot regenerated on top of it:

- 0011_add_git_stack_only_running_services.sql -> 0012_...
- 0012_snapshot.json rebuilt from main's 0011 snapshot, prevId chained to it
- journal keeps main's idx 11 and appends idx 12

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
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.

[Feature Request] Option to only restart previously running services on "Sync from Git" for Stack

3 participants