Skip to content
Merged
Show file tree
Hide file tree
Changes from 22 commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
f4c1fd2
Remove leftover definitions
WilliamRoebuck Aug 24, 2026
50ba1ab
Alive monitor changes to expose factory
WilliamRoebuck Aug 24, 2026
9d25525
PIN uses factory, integration tests pass
WilliamRoebuck Aug 24, 2026
ccb5664
Remove construct method
WilliamRoebuck Aug 27, 2026
d0a26c1
Cleanup
WilliamRoebuck Aug 27, 2026
059727b
Fix UTs
WilliamRoebuck Aug 27, 2026
3325909
Fix wrong member name
WilliamRoebuck Aug 28, 2026
a8f71ca
Superficial cleanup
WilliamRoebuck Aug 28, 2026
e339ab9
Move supervision factory into struct
WilliamRoebuck Aug 28, 2026
f5cc8b4
Apply suggestions
WilliamRoebuck Aug 31, 2026
84780eb
Fixes after rebase
WilliamRoebuck Aug 31, 2026
1a33227
Merge branch 'main' of https://github.com/eclipse-score/inc_lifecycle…
WilliamRoebuck Sep 1, 2026
cefd51c
Initial cleanup
WilliamRoebuck Sep 2, 2026
2290950
Rename supervision_event_publisher
WilliamRoebuck Sep 2, 2026
d590b6d
Handle failed construction
WilliamRoebuck Sep 2, 2026
587f377
Extract init method
WilliamRoebuck Sep 2, 2026
05759f4
Stop alive config invalidation
WilliamRoebuck Sep 2, 2026
5a021a7
Merge branch 'main' of https://github.com/eclipse-score/inc_lifecycle…
WilliamRoebuck Sep 2, 2026
c79250c
Rename supervision state reporter
WilliamRoebuck Sep 3, 2026
a8be15a
Merge branch 'main' of https://github.com/eclipse-score/inc_lifecycle…
WilliamRoebuck Sep 3, 2026
d1632c7
Merge branch 'main' into feature/process-makes-supervision
WilliamRoebuck Sep 4, 2026
dd75780
Merge branch 'main' into feature/process-makes-supervision
WilliamRoebuck Sep 4, 2026
9bcbfc4
Address comments
WilliamRoebuck Sep 4, 2026
53defd2
Merge branch 'main' of https://github.com/eclipse-score/inc_lifecycle…
WilliamRoebuck Sep 4, 2026
4aa5888
Fixed oversight
WilliamRoebuck Sep 4, 2026
ef72b5e
Merge branch 'main' of https://github.com/eclipse-score/inc_lifecycle…
WilliamRoebuck Sep 4, 2026
5355391
Correct condition
WilliamRoebuck Sep 4, 2026
59cf158
Merge branch 'main' of https://github.com/eclipse-score/inc_lifecycle…
WilliamRoebuck Sep 4, 2026
319037a
Merge branch 'main' into feature/process-makes-supervision
WilliamRoebuck Sep 7, 2026
0b4ff91
Suggestions
WilliamRoebuck Sep 7, 2026
9bd7881
Renames
WilliamRoebuck Sep 7, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions score/launch_manager/src/daemon/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,7 @@ cc_binary(
"//score/launch_manager/src/daemon/src/configuration:flatbuffer_config_loader",
"//score/launch_manager/src/daemon/src/osal:ipc_comms",
"//score/launch_manager/src/daemon/src/process_group_manager",
"//score/launch_manager/src/daemon/src/process_group_manager:alive_monitor_thread",
"//score/launch_manager/src/daemon/src/recovery_client",
"//score/launch_manager/src/daemon/src/supervision_control_client:supervision_control_notifier",
"//score/launch_manager/src/daemon/src/watchdog:watchdog_factory",
"@score_baselibs//score/language/futurecpp",
],
Expand Down
24 changes: 24 additions & 0 deletions score/launch_manager/src/daemon/src/alive_monitor/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,27 @@ cc_library(
"//score/launch_manager/src/daemon/src/alive_monitor/details/daemon:health_monitor_impl",
],
)

cc_library(
name = "i_alive_monitor",
hdrs = ["IAliveMonitor.hpp"],
include_prefix = "score/mw/launch_manager/alive_monitor",
strip_include_prefix = "/score/launch_manager/src/daemon/src/alive_monitor",
visibility = ["//score:__subpackages__"],
deps = [
"//score/launch_manager/src/daemon/src/supervision_control_client:isupervision_factory",
],
)

cc_library(
name = "mock_alive_monitor",
testonly = True,
hdrs = ["mock_alive_monitor.hpp"],
include_prefix = "score/mw/launch_manager/alive_monitor",
strip_include_prefix = "/score/launch_manager/src/daemon/src/alive_monitor",
visibility = ["//score:__subpackages__"],
deps = [
":i_alive_monitor",
"@googletest//:gtest_main",
],
)
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,7 @@
#ifndef SAF_DAEMON_ALIVE_MONITOR_HPP_INCLUDED
#define SAF_DAEMON_ALIVE_MONITOR_HPP_INCLUDED

#include <atomic>

#include "score/mw/launch_manager/alive_monitor/details/daemon/PhmDaemon.hpp"
#include "score/mw/launch_manager/supervision_control_client/isupervision_factory.hpp"

namespace score::mw::lifecycle::internal::saf::daemon
{
Expand All @@ -26,13 +24,21 @@ class IAliveMonitor
public:
virtual ~IAliveMonitor() = default;

/// @brief Initialize the AliveMonitor functionality
/// @return kNoError if initialization was successful, otherwise an appropriate error code.
virtual EInitCode init() noexcept = 0;
/// @brief Start the monitor thread
/// @warning Not valid if @c init() failed
virtual bool start() = 0;
Comment thread
MaciejKaszynski marked this conversation as resolved.
Outdated

/// @brief Stop the monitor thread
/// @warning Not valid if @c init() failed
virtual void stop() = 0;

/// @brief Run the AliveMonitor functionality in a cyclic manner until cancellation is requested.
/// @param cancel_thread Atomic boolean flag to signal thread cancellation.
virtual bool run(std::atomic_bool& cancel_thread) noexcept = 0;
/// @brief Returns an interface for components to register their alive supervision
/// @warning Not valid if @c init() failed
virtual ISupervisionFactory& getSupervisionFactory() const = 0;

/// @brief Initialize the AliveMonitor functionality
/// @return True if initialization was successful, false otherwise.
virtual bool init() noexcept = 0;
};

} // namespace score::mw::lifecycle::internal::saf::daemon
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,14 @@ cc_library(
visibility = ["//score/launch_manager/src/daemon/src/alive_monitor:__subpackages__"],
)

cc_library(
name = "einitcode",
hdrs = ["EInitCode.hpp"],
include_prefix = "score/mw/launch_manager/alive_monitor/details/common",
strip_include_prefix = "/score/launch_manager/src/daemon/src/alive_monitor/details/common",
visibility = ["//score/launch_manager/src/daemon/src/alive_monitor:__subpackages__"],
)

cc_library(
name = "locked_vector",
hdrs = ["LockedVector.hpp"],
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
/********************************************************************************
* Copyright (c) 2026 Contributors to the Eclipse Foundation
*
* See the NOTICE file(s) distributed with this work for additional
* information regarding copyright ownership.
*
* This program and the accompanying materials are made available under the
* terms of the Apache License Version 2.0 which is available at
* https://www.apache.org/licenses/LICENSE-2.0
*
* SPDX-License-Identifier: Apache-2.0
********************************************************************************/

#ifndef E_INIT_CODE_HPP_INCLUDED
#define E_INIT_CODE_HPP_INCLUDED

#include <cstdint>

namespace score::mw::lifecycle::internal::saf::daemon
{

/// @brief Return codes for PhmDaemon Initialization
enum class EInitCode : std::int8_t
{
kNoError, ///< Init Successful (no error occurred)
kNotInitialized, ///< Init was not performed
kCycleTimeInitFailed, ///< Cyclic Timer initialization failed
kConstructFlatCfgFactoryFailed, ///< FlatCfgFactory failed loading SWCL configurations
kGeneralError ///< General error
};

} // namespace score::mw::lifecycle::internal::saf::daemon

#endif
Original file line number Diff line number Diff line change
Expand Up @@ -11,40 +11,38 @@
* SPDX-License-Identifier: Apache-2.0
********************************************************************************/
#include <sys/types.h>

#include <iostream>

#include <score/assert.hpp>

#include "score/mw/launch_manager/alive_monitor/details/daemon/AliveMonitorImpl.hpp"
#include "score/mw/launch_manager/alive_monitor/details/daemon/PhmDaemon.hpp"

namespace score::mw::lifecycle::internal::saf::daemon
{

AliveMonitorImpl::AliveMonitorImpl(
SptrIRecoveryClient recovery_client,
UptrISupervisionControlReceiver observable_event_receiver,
const Config& config)
: m_recovery_client(recovery_client),
m_observable_event_receiver(std::move(observable_event_receiver)),
m_config(config)
AliveSupervisionConfig config,
const std::size_t supervised_components)
: m_recovery_client(recovery_client), config_(config), supervised_components_(supervised_components)
{
}

EInitCode AliveMonitorImpl::init() noexcept
bool AliveMonitorImpl::init() noexcept
{
EInitCode initResult{EInitCode::kGeneralError};
try
{
m_osClock.startMeasurement();

m_daemon = std::make_unique<PhmDaemon>(m_osClock, std::move(m_observable_event_receiver));
initResult = m_daemon->init(m_recovery_client, m_config);
m_daemon = std::make_unique<PhmDaemon>(m_osClock, supervised_components_);
EInitCode initResult = m_daemon->init(m_recovery_client, config_);

if (initResult == EInitCode::kNoError)
{
const long ms{m_osClock.endMeasurement()};
LM_LOG_DEBUG() << "AliveMonitor: Initialization took " << ms << " ms";
return true;
}
else
{
Expand All @@ -54,22 +52,43 @@ EInitCode AliveMonitorImpl::init() noexcept
catch (const std::exception& e)
{
std::cerr << "AliveMonitor: Initialization failed due to standard exception: " << e.what() << ".\n";
initResult = EInitCode::kGeneralError;
}
catch (...)
{
std::cerr << "AliveMonitor: Initialization failed due to exception!\n";
initResult = EInitCode::kGeneralError;
}

return initResult;
return false;
}

bool AliveMonitorImpl::run(std::atomic_bool& cancel_thread) noexcept
bool AliveMonitorImpl::start() noexcept
{
alive_monitor_thread_ = std::thread([this]() {
threadFn(stop_thread_);
});

return true;
}

void AliveMonitorImpl::stop() noexcept
{
stop_thread_.store(true);
if (alive_monitor_thread_.joinable())
{
alive_monitor_thread_.join();
}
}

bool AliveMonitorImpl::threadFn(std::atomic_bool& cancel_thread) noexcept
{
SCORE_LANGUAGE_FUTURECPP_PRECONDITION_PRD_MESSAGE(
m_daemon != nullptr, "HealthMonitor: Instance is not initialized!");
return m_daemon->startCyclicExec(cancel_thread);
}

ISupervisionFactory& AliveMonitorImpl::getSupervisionFactory() const noexcept
{
return *m_daemon;
Comment thread
WilliamRoebuck marked this conversation as resolved.
}

} // namespace score::mw::lifecycle::internal::saf::daemon
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,10 @@

#include <atomic>
#include <memory>
#include <thread>

#include "score/mw/launch_manager/alive_monitor/details/daemon/IAliveMonitor.hpp"
#include "score/mw/launch_manager/alive_monitor/IAliveMonitor.hpp"
#include "score/mw/launch_manager/alive_monitor/details/daemon/PhmDaemon.hpp"
#include "score/mw/launch_manager/configuration/config.hpp"

namespace score::mw::lifecycle
Expand All @@ -28,30 +30,47 @@ namespace internal::saf::daemon
{

using SptrIRecoveryClient = std::shared_ptr<score::mw::lifecycle::IRecoveryClient>;
using UptrISupervisionControlReceiver = std::unique_ptr<score::mw::lifecycle::ISupervisionControlReceiver>;
using UptrPhmDaemon = std::unique_ptr<score::mw::lifecycle::internal::saf::daemon::PhmDaemon>;
using OsClock = score::mw::lifecycle::internal::saf::timers::OsClockInterface;
using Config = score::mw::lifecycle::internal::configuration::Config;
using score::mw::lifecycle::internal::configuration::AliveSupervisionConfig;
using configuration::AliveSupervisionConfig;

class AliveMonitorImpl : public IAliveMonitor
{
static_assert(
std::is_trivially_copyable_v<AliveSupervisionConfig>,
"AliveSupervisionConfig is copied to this object since it is trivially copyable. If this changes, it should be "
"passed by move instead");

public:
AliveMonitorImpl(
SptrIRecoveryClient recovery_client,
UptrISupervisionControlReceiver observable_event_receiver,
const Config& config);
AliveSupervisionConfig config,
const std::size_t supervised_components);

/// @brief @see IAliveMonitor definition
bool start() noexcept override;
Comment thread
WilliamRoebuck marked this conversation as resolved.
Outdated
Comment thread
MaciejKaszynski marked this conversation as resolved.
Outdated

EInitCode init() noexcept override;
/// @brief @see IAliveMonitor definition
void stop() noexcept override;

bool run(std::atomic_bool& cancel_thread) noexcept override;
/// @brief @see IAliveMonitor definition
ISupervisionFactory& getSupervisionFactory() const noexcept override;
Comment thread
WilliamRoebuck marked this conversation as resolved.
Outdated

/// @brief @see IAliveMonitor definition
bool init() noexcept override;

private:
/// @brief Run the AliveMonitor functionality in a cyclic manner until cancellation is requested.
/// @param cancel_thread Atomic boolean flag to signal thread cancellation.
bool threadFn(std::atomic_bool& cancel_thread) noexcept;

SptrIRecoveryClient m_recovery_client{nullptr};
UptrPhmDaemon m_daemon{nullptr};
OsClock m_osClock{};
UptrISupervisionControlReceiver m_observable_event_receiver;
const Config& m_config;
AliveSupervisionConfig config_;
std::thread alive_monitor_thread_{};
std::atomic_bool stop_thread_{false};
std::size_t supervised_components_;
Comment thread
MaciejKaszynski marked this conversation as resolved.
};

} // namespace internal::saf::daemon
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ cc_library(
deps = [
":phm_daemon_config",
":sw_cluster_handler",
"//score/launch_manager/src/daemon/src/alive_monitor/details/common:einitcode",
"//score/launch_manager/src/daemon/src/alive_monitor/details/factory:flat_cfg_factory",
"//score/launch_manager/src/daemon/src/alive_monitor/details/ifappl:monitor_if_daemon",
"//score/launch_manager/src/daemon/src/alive_monitor/details/ifexm:observable_event_reader",
Expand All @@ -59,18 +60,10 @@ cc_library(
"//score/launch_manager/src/daemon/src/alive_monitor/details/timers:cycle_timer",
"//score/launch_manager/src/daemon/src/alive_monitor/details/timers:timers_os_clock",
"//score/launch_manager/src/daemon/src/common:log",
"//score/launch_manager/src/daemon/src/supervision_control_client:isupervision_factory",
],
)

cc_library(
name = "i_health_monitor",
hdrs = ["IAliveMonitor.hpp"],
include_prefix = "score/mw/launch_manager/alive_monitor/details/daemon",
strip_include_prefix = "/score/launch_manager/src/daemon/src/alive_monitor/details/daemon",
visibility = ["//score/launch_manager/src/daemon:__subpackages__"],
deps = [":phm_daemon"],
)

cc_library(
name = "health_monitor_impl",
srcs = ["AliveMonitorImpl.cpp"],
Expand All @@ -79,7 +72,8 @@ cc_library(
strip_include_prefix = "/score/launch_manager/src/daemon/src/alive_monitor/details/daemon",
visibility = ["//score/launch_manager/src/daemon:__subpackages__"],
deps = [
":i_health_monitor",
":phm_daemon",
"//score/launch_manager/src/daemon/src/alive_monitor:i_alive_monitor",
"//score/launch_manager/src/daemon/src/configuration:config",
"@score_baselibs//score/language/futurecpp",
],
Expand Down
Loading
Loading