Skip to content

ADFA-4842: module install — stop and restart the server around the runroles - #299

Merged
luisguzman-adfa merged 6 commits into
mainfrom
feat/ADFA-4842-module-restart
Jul 30, 2026
Merged

ADFA-4842: module install — stop and restart the server around the runroles#299
luisguzman-adfa merged 6 commits into
mainfrom
feat/ADFA-4842-module-restart

Conversation

@luisguzman-adfa

Copy link
Copy Markdown
Collaborator

What

A module (proot) install runs its runroles with the server stopped, so it needs its own
handling in the setup index rather than reusing the REST content flow (which assumes the
server stays up).

Changes

  • InstallService stops the server (pdsm stop) before a real module batch's runroles; a
    maps-only batch skips it. Clears the install guard before signaling DONE.
  • The setup index drives a module install without the REST readiness wait: it does not try
    to start services mid-runrole, restarts the server after the queue finishes, and redirects
    only once the REST core answers — landing on the Library (Home) tab.
  • The index is locked for the whole module session: Back backgrounds the app instead of
    walking back into a half-built flow.
  • Status reads "Modules are installing" during the runroles and "Starting services" only
    during the post-DONE restart, with an animated ellipsis (reusable util/EllipsisAnimator).

Verification

  • Install kolibri/calibreweb from Settings → Advanced → Module management: per-module
    progress, the server restarts on its own, and it lands on a live Home (previous + new
    modules).
  • Wizard maps and REST content (ZIM/Books) unchanged.

Supersedes feat/ADFA-4842-module-mgmt (#255).

… REST one

Two bugs came from recycling the REST 'finishing setup' flow for proot module installs, which
have the OPPOSITE server assumption (REST runs on the live server; a module install stops it
and runs its own proot). Fixed, scoped to a module install (moduleInSession) so REST and
REST+proot (mixed), which already work serialized, are untouched:

1. Loop escape: onBackPressed only trapped on the derived prootActive(), which has gaps, so
   Back could walk back through the hub/Settings steps. Now a module install hard-locks the
   index for its whole (durable) session — Back only ever backgrounds the app; reopening
   resumes here.
2. 'Starting services' during a proot install: readyPoll waited for the REST engine (apiReady)
   and showed REST wording even though the server is intentionally down — and on reopen sat
   there implying it should start the server (a second proot) mid-runrole. A module install now
   skips the REST readiness gate entirely (the runrole queue drives progress; the server is
   restarted only after DONE) and the status reads 'Modules are installing', with 'Starting
   services' reserved for the real post-DONE restart.
…orall/iiab-android into feat/ADFA-4842-module-restart
…ad server

Regression analysis (3rd time landing on a dead Library after a module install): the
post-install 'start + wait' call (SetupProgressActivity.ensureServerUpForModules →
handleServerLaunchClick) is intact. The gap is the DESTINATION: goHome returns to the REUSED
LibraryActivity via onNewIntent, and only onCreate carried the server autostart — so a reused
Home never (re)starts the server and simply inherits whatever state was left. When the earlier
cold-boot recreate was reverted (fresh onCreate → reuse), that destination-side start was lost.

Fix: onNewIntent now runs the same guarded autostart as onCreate (extracted to
maybeAutostartServer). Returning Home after any install drives the server up when it's installed
and down, never inheriting a dead state. No-op when already alive/starting or an install/guard is
in flight. (A genuine pdsm-start failure is separate and needs the device log; the 45s
server-up timeout in the index also masks such a failure as success — noted for follow-up.)
…oggle)

Device log root cause: after the last runrole, the index called handleServerLaunchClick — a
TOGGLE (start if !alive, STOP if alive). The runrole proot exits with --kill-on-exit, killing
the services it had (re)started, but the app's cached 'alive' still read TRUE for a moment, so
the toggle STOPPED the environment ('Stopping IIAB environment gracefully' in the log) and the
user landed on a dead Home; ~45s later Home's autostart recovered it.

Mechanism (documented in code so it isn't broken lightly): each module runrole runs its own proot
= clean start -> tasks -> clean stop, so the environment is DOWN when the batch ends (correct for
several modules in series). The INDEX is the actuator that brings it back after the LAST module —
UNCONDITIONALLY. REST content installs run on the live server (never down); different world.

- ServerController.startEnvironment(): unconditional pdsm start, extracted from the toggle's start
  branch (handleServerLaunchClick still calls it, keeping toggle semantics for the UI button).
- SetupProgressActivity.ensureServerUpForModules() calls startEnvironment() (never the toggle),
  with a comment block explaining why.
- serverUpPoll timeout no longer declares silent success: it surfaces a failure (Finish + note),
  so a server that won't come up is reported, not hidden.
- LibraryActivity stays a MONITOR (reverted the onNewIntent autostart): Home never starts the
  server; the actuators are app launch (onCreate) and the index.
@luisguzman-adfa
luisguzman-adfa merged commit 3f6b31c into main Jul 30, 2026
3 checks passed
@luisguzman-adfa
luisguzman-adfa deleted the feat/ADFA-4842-module-restart branch July 30, 2026 23:57
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.

1 participant