Add cpp_supervised_app_simple example for the Alive API#362
Open
Narasimha2211 wants to merge 1 commit into
Open
Add cpp_supervised_app_simple example for the Alive API#362Narasimha2211 wants to merge 1 commit into
Narasimha2211 wants to merge 1 commit into
Conversation
…e#234) Adds a minimal example showcasing score::mw::lifecycle::Alive, as requested: construct Alive, report Running, then ReportAlive() in a loop until SIGTERM/SIGINT, with no deadline/checkpoint supervision (that's what distinguishes it from the existing cpp_supervised_app, which uses the HealthMonitor/DeadlineMonitor API instead). - examples/cpp_supervised_app_simple/main.cpp + BUILD: modeled closely on cpp_supervised_app's structure (signal handling, set_process_name, getopt-based CLI with -s <sleep-ms>), swapping the HealthMonitor block for score::mw::lifecycle::Alive + report_running(). Depends on the //score/launch_manager:alive_cc and :lifecycle_cc aliases (same public-alias pattern the existing examples already use, since the underlying alive/lifecycle_client targets have restricted visibility). Alive construction can throw per its documented contract, so it's wrapped in try/catch for a clean error message instead of an unhandled-exception terminate(). - Registered as a new "cpp_supervised_app_simple" component in examples/demo_verification/lifecycle_demo_test.json, added to the Running run target's depends_on. Left application_type unset (defaults to "Reporting", same as lifecycle_app) since this app only demonstrates the alive heartbeat, not deadline-checkpoint supervision -- happy to change to Reporting_And_Supervised if a maintainer prefers that classification. - Added the new binary to demo_verification/BUILD's integration_test binaries list and to test_examples.py's _DEMO_APPS. - Documented the new app in examples/README.md's app table. Found and fixed a real bug while wiring up the demo config: this app's name is a literal prefix-superstring of the existing "cpp_supervised_app", and test_examples.py's process-matching was a plain unanchored substring grep over /proc/*/cmdline. That means grep -qa 'cpp_supervised_app' would also match "cpp_supervised_app_simple"'s cmdline -- breaking _assert_not_running(target, "cpp_supervised_app") after the existing SIGKILL crash-recovery step (it would spuriously find the still-alive _simple process and report the killed app as still running). Verified this concretely by simulating /proc/*/cmdline-style files locally (NUL-separated argv, both bare-name and full-path forms) and reproducing the false match, then fixing test_examples.py's _assert_running/_assert_not_running/_send_signal to convert cmdline's NUL-separated argv into one-token-per-line and anchor the match (^binary$ or ^.*/binary$) instead of doing a raw substring search -- re-ran the same simulation against the fixed logic and confirmed it correctly distinguishes the two names, still matches full-path argv0, and doesn't self-match the invoking shell's own command line (the anchoring incidentally subsumes the original bracket-class self-match-avoidance trick, so I dropped it). Verification note: this repo requires Bazel, which isn't available in my environment, so I could not build or run the integration test. Everything above was verified by reading the actual headers (score/launch_manager/src/alive/src/alive.h, .../lifecycle_client/src/report_running.h) and BUILD files to confirm target names, include paths, and visibility, by closely mirroring the existing cpp_supervised_app example, and by empirically simulating the test_examples.py matching logic outside Bazel as described above. CI should be treated as the real verification here.
Narasimha2211
requested a deployment
to
workflow-approval
July 23, 2026 20:22 — with
GitHub Actions
Waiting
Narasimha2211
requested a deployment
to
workflow-approval
July 23, 2026 20:22 — with
GitHub Actions
Waiting
License Check Results🚀 The license check job ran with the Bazel command: bazel run --lockfile_mode=error //:license-checkStatus: Click to expand output |
|
The created documentation from the pull request is available at: docu-html |
| } | ||
| } | ||
|
|
||
| void set_process_name() |
Contributor
There was a problem hiding this comment.
I think we could remove this. This is not required for the functionality. In some other sample app we had this only for some demo purpose.
NicolasFussberger
requested changes
Jul 27, 2026
NicolasFussberger
left a comment
Contributor
There was a problem hiding this comment.
Looks good to me @Narasimha2211. Thanks for your contribution!
I only added a minor comment.
Please ensure you have an eclipse account linked to your github account so that we can merge your contribution
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.
Closes #234
What
Adds
examples/cpp_supervised_app_simple, a minimal example ofscore::mw::lifecycle::Alive: constructAlive, reportRunning, then callReportAlive()in a loop untilSIGTERM/SIGINT. No deadline/checkpoint supervision — that's what distinguishes it from the existingcpp_supervised_app, which uses theHealthMonitor/DeadlineMonitorAPI instead.How
main.cpp/BUILDare modeled closely oncpp_supervised_app's structure (signal handling,set_process_name,getopt-based CLI with-s <sleep-ms>), swapping theHealthMonitorblock forscore::mw::lifecycle::Alive+report_running(). Depends on the//score/launch_manager:alive_ccand:lifecycle_ccaliases — the same public-alias pattern the existing examples already use, since the underlyingalive/lifecycle_clienttargets have restricted visibility.Alive's constructor can throw per its documented contract, so it's wrapped intry/catchfor a clean error message instead of an unhandled-exceptionterminate().cpp_supervised_app_simplecomponent inexamples/demo_verification/lifecycle_demo_test.json, added to theRunningrun target'sdepends_on. Leftapplication_typeunset (defaults to"Reporting", same aslifecycle_app) since this app only demonstrates the alive heartbeat, not deadline-checkpoint supervision — happy to switch toReporting_And_Supervisedif that's the preferred classification.demo_verification/BUILD'sintegration_testbinarieslist and totest_examples.py's_DEMO_APPS.examples/README.md's table.A bug I found and fixed along the way
Wiring this into the demo config surfaced a real, pre-existing bug:
cpp_supervised_app_simpleis a literal prefix-superstring ofcpp_supervised_app, andtest_examples.py's process matching was a plain unanchored substringgrepover/proc/*/cmdline. That meansgrep -qa 'cpp_supervised_app'would also matchcpp_supervised_app_simple's cmdline — breaking_assert_not_running(target, "cpp_supervised_app")right after the existing SIGKILL crash-recovery step (it would spuriously find the still-alive_simpleprocess and report the killed app as still running, false-negating that assertion).I verified this concretely (not just by inspection) by simulating
/proc/*/cmdline-style files locally — NUL-separated argv, both bare-name and full-path forms — and reproducing the false match. Then I fixed_assert_running/_assert_not_running/_send_signalto turn cmdline's NUL-separated argv into one-token-per-line and anchor the match (^binary$or^.*/binary$) instead of a raw substring search, and re-ran the same simulation against the fixed logic to confirm it: distinguishes the two names correctly, still matches full-pathargv[0], and doesn't self-match the invoking shell's own command line (the anchoring subsumes the original bracket-class self-match-avoidance trick, so I dropped that in favor of the anchor).Verification note
This repo requires Bazel, which isn't available in my environment, so I could not build or run the integration test end-to-end. What I did verify:
score/launch_manager/src/alive/src/alive.h,.../lifecycle_client/src/report_running.h) to confirm the API surface, include paths, and target/alias visibility.cpp_supervised_appexample.test_examples.pymatching-logic bug and fix outside Bazel, as described above.python3 -m json.toolon the modifiedlifecycle_demo_test.jsonandast.parseontest_examples.py— both syntactically valid.CI should be treated as the real verification here — happy to iterate on anything that doesn't hold up once it actually builds and runs.