Task #6125
openTask #6116: EPIC: Speed up the stats updater daemon (scripts/workflow/update_stats.sh)
Run one round in a single JVM instead of 10 separate launches
90%
Description
Problem¶
scripts/workflow/update_stats.sh shells out to 10 wrapper scripts per round, each of which is a fresh java -jar launch. Every launch pays for JVM start, Micronaut context creation, Flyway migration check and Hikari pool setup, and throws away all JIT warm-up from the previous step. The wrappers themselves also re-read VERSION via $(cat VERSION) on each call.
Proposed change¶
Add a run-stats-round command to Application.kt that executes the same sequence in-process:
sync-dialogs-with-users → generate-user-partner-connections → download-companies-from-iiko → download-employees-from-iiko → distribute-employees-companies-partners → obsolete-companies → download-trading-point-inspections → iiko-partner-metrics-sync → iiko-stats-data-sync → iiko-users-metrics-sync
- A failing step logs and the round continues to the next step (matching today's behaviour, where each script exits independently).
- Combined with the session-reuse task, one IIKO session then covers the whole round rather than being re-established ten times.
- The daemon loop shrinks to a single call plus its notification.
Keep the individual commands working standalone — they are used for manual repair runs.
Acceptance¶
-
run-stats-roundperforms the full sequence in one process. - Individual commands still run standalone.
-
update_stats.shupdated to call it.