feat(tamanu): expected-services model + robust pm2 discovery on Windows#336
Merged
Conversation
5ea5c28 to
709a882
Compare
709a882 to
0400646
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Replaces the doctor's
tamanu_servicehealthcheck with a declarativeexpected-services model and adds a robust pm2 discovery path for Windows.
Expected-services model
tamanu::servicesmodule:Supervisor,ServerKind(fromApiServerKind),Expectation,Instances(Single/NumericAtLeast(n)/Named(&[…])),ExpectedState(Up/Down), plus anexpected(supervisor, kind, &config)function.taskssingleton;frontend@a/@band forbiddentamanu-facilitysingleton on systemd;api≥2; Centralfhir-resolve/fhir-refreshwhenfhir.worker.enabled; Facilitysyncsingleton.fhir.worker.enabledfield onTamanuConfig.Doctor check
tamanu-*units/processes, matches each expectation, diagnoses missing / shortfall / forbidden / not-running. Unrelatedtamanu-*services are recorded as informational extras rather than counted against the check.systemctl is-enabledfor any forbidden unit that didn't show up loaded.pm2 discovery on Windows
tamanu::pm2module. The doctor no longer callsCommand::new("pm2")directly.BESTOOL_PM2_COMMAND, thenpm2.cmd/pm2.bat, then common npm-global install paths andC:\pm2\pm2.cmd.PM2_HOME/dump.pm2directly and checkingPM2_HOME/pids/<name>-<id>.pidagainst the OS process list (via sysinfo). CandidatePM2_HOMElocations: env var,C:\pm2,~/.pm2.cli/dump) surfaces in the check details.Tests cover the expected() matrix, the matching logic with synthetic discovered lists, and pm2 dump+pid parsing with tempdir fixtures.