Skip to content

Run the crypto daemon under score::mw::lifecycle::run_application - #475

Open
prabakaranklst wants to merge 1 commit into
eclipse-score:mainfrom
qorix-group:prabakaran_run_daemon_under_lifecycle
Open

prabakaranklst wants to merge 1 commit into
eclipse-score:mainfrom
qorix-group:prabakaran_run_daemon_under_lifecycle

Conversation

@prabakaranklst

Copy link
Copy Markdown
Contributor

Description

The crypto daemon now runs as an S-CORE lifecycle application instead of managing its own process lifecycle.
Until now, main() installed a SIGINT/SIGTERM handler, polled a global flag every 100 ms, and never reported its state to the Launch Manager.

With score::mw::lifecycle::run_application, the daemon reports kRunning once its IPC server is listening.
If Launch Manager is used, it can then start crypto clients only after the daemon is ready, stop them before the daemon, and restart the daemon if it crashes.
The daemon still runs without a Launch Manager; it then logs that the kRunning report failed and keeps running.

Changes:

  • CryptoDaemon (score/crypto/src/daemon/src/crypto_daemon.{hpp,cpp}) derives from score::mw::lifecycle::Application.
    • Initialize() parses the config, creates the provider manager, data manager and key management, and starts the control server. Any failure returns EXIT_FAILURE, so kRunning is never reported.
    • Run() waits on the stop token, which fires on SIGTERM, then stops the server and waits for sessions to close.
  • main() is reduced to the run_application<CryptoDaemon> call. The hand-written signal handling and polling loop are removed.
  • IDaemonComponentFactory covers the three steps that need the environment: config parsing, provider manager creation and control server creation. DaemonComponentFactory is the production implementation; unit tests replace it with a mock.
  • Build:
    • New bazel_dep on score_lifecycle 0.10.1. It pins the same score_baselibs (0.2.18) and score_communication (0.6.0) as this repo.
    • score/crypto/src/daemon/BUILD is split into crypto_daemon_lib, the crypto_daemon binary and the test targets. The binary keeps its dynamic_deps for @score_openssl//:dynamic_openssl_enabled.
  • ProcessRunner.start() records the exit status of the started process, and the new exit_code() returns it. The ITF test now checks that the daemon exits with 0 after SIGTERM, and that it refuses to start with an invalid config file.

Behaviour changes:

  • LifeCycleManager handles SIGTERM only, so SIGINT (Ctrl+C) now ends the daemon without draining sessions. CI and the ITF tests stop the daemon with SIGTERM.
  • When the daemon is started by the Launch Manager, its launch configuration should use kRunning as the ready condition.

Out of scope:

  • Graceful shutdown on SIGINT.
  • Alive notifications and health monitoring integration.
  • A real authorization callback. The existing allow-all callback is unchanged.

Related ticket

closes #470

@github-actions

Copy link
Copy Markdown
Contributor

License Check Results

🚀 The license check job ran with the Bazel command:

bazel run --lockfile_mode=error //:license-check

Status: ⚠️ Needs Review

Click to expand output
[License Check Output]
Extracting Bazel installation...
Starting local Bazel server (8.8.2) and connecting to it...
INFO: Invocation ID: 75a105cf-bdbe-4f80-95cf-4f6deedc6fef
Computing main repo mapping: 
Computing main repo mapping: 
Computing main repo mapping: 
WARNING: For repository 'rules_python', the root module requires module version rules_python@1.8.5, but got rules_python@1.9.0 in the resolved dependency graph. Please update the version in your MODULE.bazel or set --check_direct_dependencies=off
WARNING: For repository 'score_bazel_platforms', the root module requires module version score_bazel_platforms@0.1.2, but got score_bazel_platforms@1.3.0 in the resolved dependency graph. Please update the version in your MODULE.bazel or set --check_direct_dependencies=off
WARNING: For repository 'rules_cc', the root module requires module version rules_cc@0.2.22, but got rules_cc@0.2.26 in the resolved dependency graph. Please update the version in your MODULE.bazel or set --check_direct_dependencies=off
Computing main repo mapping: 
Computing main repo mapping: 
Loading: 
Loading: 1 packages loaded
Loading: 1 packages loaded
    currently loading: 
Loading: 1 packages loaded
    currently loading: 
Loading: 1 packages loaded
    currently loading: 
Loading: 1 packages loaded
    currently loading: 
Loading: 1 packages loaded
    currently loading: 
WARNING: Target pattern parsing failed.
ERROR: Skipping '//:license-check': no such target '//:license-check': target 'license-check' not declared in package '' defined by /home/runner/work/crypto/crypto/BUILD
ERROR: no such target '//:license-check': target 'license-check' not declared in package '' defined by /home/runner/work/crypto/crypto/BUILD
INFO: Elapsed time: 16.340s
INFO: 0 processes.
ERROR: Build did NOT complete successfully
ERROR: Build failed. Not running target

This branch is waiting to be deployed

1 waiting deployment
workflow-approval — ea4c4a4c Waiting Nov 24, 2026 by prabakaranklst via Build and Test x86_64-qnx-itf / approval #1210
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Backlog

Development

Successfully merging this pull request may close these issues.

Run the crypto daemon under score::mw::lifecycle::run_application

1 participant