Skip to content

fix(service): recreate a stopped global service from the compose file on enable - #84

Merged
mrrobot47 merged 3 commits into
EasyEngine:developfrom
mrrobot47:fix/enable-stopped-service-compose
Nov 16, 2026
Merged

mrrobot47 merged 3 commits into
EasyEngine:developfrom
mrrobot47:fix/enable-stopped-service-compose

Conversation

@mrrobot47

@mrrobot47 mrrobot47 commented Oct 23, 2026 •

Copy link
Copy Markdown
Member

ee service enable <service> started an existing stopped container with docker start, so the service came back on the image and config the container was created with, whatever the global compose file says now.

An EasyEngine upgrade only recreates the global services that are running. It leaves a stopped one as it is and writes the new tag to the global compose file (EasyEngine/easyengine#1954, which this complements). With docker start, enabling that service kept the old image. On hosts where an earlier upgrade's network cleanup had removed its network, docker start failed outright, while the command still printed "Service … enabled."

ee service enable now runs docker-compose up -d <service> for a container that isn't running:

  • an unchanged container is just started;
  • a container whose image or config no longer matches the compose file is recreated (Compose pulls a missing image);
  • a missing network is created.

If that fails, the command reports an error instead of success. nginx-proxy already went through up -d. The other callers of init_global_container() (site create, cron) keep docker start, so they never recreate a database or redis as a side effect.

This also repairs hosts that an earlier upgrade left with a stopped service on its old image.

Testing

Fork CI upgrade end to end (run 40019379300): stable 4.13.3, with the global database killed and redis disabled, upgraded to a 4.13.4 phar with new image tags, built with this change:

  • On top of the core PR, ee service enable db and ee service enable redis bring both up on their new images.
  • On top of #1953 alone, where the upgrade records the new tags but leaves both containers on the old images and removes their network, ee service enable also brings both up on their new images. Without this change, the database stays down.

Summary by CodeRabbit

  • Bug Fixes
    • Improved startup handling for non-proxy services. When a service cannot be started, the app now reports a startup error instead of continuing as though startup succeeded. Existing proxy service behavior remains unchanged.

… on enable

`ee service enable` started an existing stopped container with `docker start`, so it came back on whatever image and config it was created with. An EasyEngine upgrade leaves a stopped global service as it is (on its old image, with the old tag recorded) and only regenerates the global compose file with the new tag, so enabling it kept the old image; and where an upgrade's network cleanup had removed its network, `docker start` failed while the command still reported success.

`ee service enable <service>` now runs `docker-compose up -d <service>` for a container that isn't running: an unchanged container is just started, one whose image or config no longer matches the compose file is recreated (Compose pulls a missing image), and a missing network is created. A failure is reported as an error instead of "Service … enabled." nginx-proxy already goes through `up -d`. Other callers of `init_global_container()` (site create, cron) keep `docker start`, so they never recreate a database or redis as a side effect.

This also repairs hosts where an earlier upgrade left a stopped service on its old image.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

The change is narrowly scoped, preserves existing callers’ behavior, and has no identified blocking issues.

No open issues 🎉

What changed in this PR

Updates ee service enable to bring stopped global services up from the current Compose configuration, applying image and configuration changes left pending by an upgrade.

Changes:

  • Opts service enable into docker-compose up -d for services that are not running.
  • Reports Compose startup failures instead of printing success.
  • Preserves existing startup behavior for other callers, including site creation and cron.
File Description
src/​Service_Command.php Enables Compose-based startup for global services.
src/​helper/​service-utils.php Adds an optional recreation mode with startup error handling.

Review effort: Balanced

@coderabbitai

coderabbitai Bot commented Nov 16, 2026 •

Copy link
Copy Markdown

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

Changes: Container recreation

Layer / File(s) Summary
Recreation option and startup path
src/helper/service-utils.php, src/Service_Command.php
init_global_container accepts a $recreate flag. For a stopped container, it runs Compose up -d and reports a startup error if execution fails when the flag is true. Otherwise, it retains the boot_container path. The non-proxy enable() path passes true.

Suggested reviewers: kirtangajjar, abhijitrakas

Change: Bug fix

Merge Risk: Minimal · up to f1089

Enabling a stopped global service now runs Compose up -d, so the service comes up on the current compose definition instead of a stale container. Other callers keep their previous startup behavior. No concrete merge-blocking risk was identified.

Security architecture risk: Minimal · up to f1089

The inspected change does not establish an introduced or worsened material security or containment risk. Service selection remains restricted, recreation requires an explicit enable operation, and existing callers retain their default behavior. The new path also explicitly handles command failure.

Retained concerns
No architecture-level concerns identified.

Security review details

Security Blast Radius

  • inferred — Operational effects can extend to sites depending on the selected shared database or cache. The generated command targets one named service, and the generated definitions supply no dependency cascade. Deployed custom Compose overrides were not available to establish their effective scope.

Trust Boundaries and Controls

  • inferred — The inspected diff does not establish new attacker-controlled service reachability or a new credential boundary: the existing service allowlist remains in front of the Docker command, and the Compose command builder is unchanged. Configuration and image reconciliation now occurs during stopped-service enable, but no newly available configuration-write authority is shown.

Resilience and Maintainability Implications

  • inferred — The explicit failure branch improves the local reporting contract compared with ignoring the boot_container result. Persistent volume declarations counter the concern that replacing the container necessarily deletes database or cache storage; they do not establish image/data compatibility or successful recovery after interruption.
Finishing Touches

Generate unit tests (beta)

  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 75cd9727-979c-49bd-889f-92c968885432
Commits

Reviewing files that changed from the base of the PR and between 3c7460e and f108969.

Files selected for processing: 2

  • src/Service_Command.php
  • src/helper/service-utils.php

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 4 remain after this review.

@mrrobot47
mrrobot47 merged commit 44acf2f into EasyEngine:develop Nov 16, 2026
15 checks passed
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.

2 participants