Skip to content

fix: wait for LocalSettings.php with external DB to prevent exit 123#176

Merged
cicalese merged 2 commits into
masterfrom
fix/external-db-entrypoint-wait
Jun 22, 2026
Merged

fix: wait for LocalSettings.php with external DB to prevent exit 123#176
cicalese merged 2 commits into
masterfrom
fix/external-db-entrypoint-wait

Conversation

@hexmode

@hexmode hexmode commented Jun 21, 2026

Copy link
Copy Markdown
Contributor

Problem

When USE_EXTERNAL_DB=true on Docker Compose, canasta create fails because the container entrypoint checks $WG_DB_TYPE before install.php has generated LocalSettings.php.

The container starts → get_mediawiki_db_var → getMediawikiSettings.php checks LocalSettings.php → not found → returns empty → $WG_DB_TYPE is empty → exit 123

Fix

When $WG_DB_TYPE is empty and USE_EXTERNAL_DB=true, retry for up to ~62 seconds to give install.php time to create LocalSettings.php.

Testing

Production-style deployment: EC2 with rootless Podman, Canasta CLI v4.2.0, image 3.5.10, external Aurora MySQL RDS.

Closes #175

When USE_EXTERNAL_DB=true, the container entrypoint runs
waitdatabase() before install.php has generated LocalSettings.php.
This causes 'Unsupported database type' and exit 123 because
$WG_DB_TYPE is empty (no LocalSettings.php to read DB config from).

Add a retry loop: when $WG_DB_TYPE is empty and USE_EXTERNAL_DB
is true, wait up to ~62 seconds for install.php to create
LocalSettings.php before giving up.

Fixes the chicken-and-egg deadlock where:
- Container needs LocalSettings.php to determine DB type
- LocalSettings.php is created by install.php
- install.php hasn't run yet when container first starts

Ref: hexmode1/icannwiki-canasta#7
@github-actions

github-actions Bot commented Jun 21, 2026

Copy link
Copy Markdown

🐳 The image based on 3339d820 commit has been built with 1.43.8-20260622-176 tag as ghcr.io/canastawiki/canasta-base:1.43.8-20260622-176

The retry only re-read WG_DB_TYPE; WG_DB_SERVER/NAME/USER/PASSWORD were
snapshotted at script start while LocalSettings.php was still empty and
stayed stale. Reload all of them once the type resolves, matching the
existing config-wait reload. Collapse the duplicated first attempt into
a single loop (same ~62s ceiling).
@cicalese

Copy link
Copy Markdown
Contributor

Pushed a small follow-up on top of this. The retry re-read only WG_DB_TYPE, but WG_DB_SERVER/NAME/USER/PASSWORD are snapshotted at script start (lines 11–14) while LocalSettings.php is still empty, so they stayed stale after the wait. Harmless on the path tested here (those vars aren't consumed on the external-DB autoupdate path), but it breaks symmetry with the existing config-wait reload at the bottom of the script. The commit reloads all the DB vars once the type resolves, and collapses the duplicated first attempt into a single loop using brace expansion ({1..31}) to match the rest of the file — same ~62 s ceiling.

@cicalese cicalese left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM

@cicalese cicalese merged commit 5b710c6 into master Jun 22, 2026
3 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.

Compose+external DB: entrypoint DB-connectivity check runs before install.php, causing exit 123

2 participants