Overpass-API icon indicating copy to clipboard operation
Overpass-API copied to clipboard

fix(entrypoint): honor STOP_AFTER_INIT if DB already initialized

Open bastien8060 opened this issue 2 months ago • 3 comments

Description: This PR ensures OVERPASS_STOP_AFTER_INIT is applied consistently in both init and clone modes.

Before, the flag was only checked when the database was freshly created. If /db/init_done already existed, the container ignored the flag and continued running, which broke automation workflows relying on idempotent init steps. Common Dev/Ops patterns separates the initialization and the serving stages.

Changes in this PR:

  • Refactored init/clone logic into helper functions early on
  • Started to re-arrange flow for better readability.
  • Finally fixed logic so that OVERPASS_STOP_AFTER_INIT is always evaluated, even if the database was already initialized.

Result: containers in init or clone mode now exit consistently when OVERPASS_STOP_AFTER_INIT=true, regardless of whether initialization work was performed.

bastien8060 avatar Sep 16 '25 12:09 bastien8060

Change is deliberately minimal and refactors made step by step leading to the change (for clarity of the review). Let me know what you think!

bastien8060 avatar Sep 16 '25 12:09 bastien8060

it just makes the behaviour (way the flags are ran) consistent, because it's not very useful (if not counterintuitive) if it were to only exit after init (which would often be done manually). Setting mode=init will always run init (if database doesn't exist), and it will always exit early if told to exit afterwards.

bastien8060 avatar Sep 16 '25 12:09 bastien8060

Since this change changes behaviour in edge-cases (even though it doesn't break normal usage), it might be worth starting to versioning and changelogs. For example, bumping a minor version: 1.4.1 to 1.5.0, signals a behavior change without actually implying full breakage.

Also, branches and tags (on both Github and Docker Hub) can be used for versioning.

bastien8060 avatar Sep 16 '25 12:09 bastien8060