Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
21 changes: 0 additions & 21 deletions examples/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,24 +32,3 @@ There is an interactive mode that walks you through two demo scenarios.
This mode requires the run.sh script to be executed **in an active tmux** session.

`cd demo && ./run.sh tmux`

There is also a recording of the demo available at [demo_recording.mp4](demo_recording.mp4).

### Demo Scenario 1: Launch Manager

![Launch Manager Demo Scenario](demo_setup1.png)

* The system is setup with four ProcessGroups, each with a Startup and Recovery state.
* By default, only the Main ProcessGroup will be started in the Startup state and remaining ProcessGroups are off initially.
* The Startup state is starting the HealthMonitor + 100 application processes, 50 of which are supervised by the HealthMonitor.
* The Recovery state is just running a single application process, that is being restarted in verbose mode when transitioning from Startup to Recovery state.
* During the demo, a non-supervised application process is killed. Subsequently, LaunchManager is detecting the crash and moving the Main ProcessGroup to the Recovery state. Now, only a single application process is running with verbose logging showing up in the console.

### Demo Scenario 2: Health Monitor

![Launch Manager Demo Scenario](demo_setup2.png)

* As explained above, the Main ProcessGroup contains 50 processes being supervised by the HealthMonitor.
* Each of these processes cyclically reports three checkpoints.
* For each of these processes, the HealthMonitor is evaluating an Alive, Deadline and Logical supervision every 50ms.
* During the demo, a supervised application is triggered to misreport checkpoints. Subsequently, supervisions for this application will fail and the HealthMonitor will initiate transition of the ProcessGroup into the Recovery state. Now, only a single application process is running with verbose logging showing up in the console.
98 changes: 0 additions & 98 deletions examples/config/gen_health_monitor_cfg.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,94 +125,6 @@ def get_alive_supervisions(index: int, process_group: str):
)


def get_deadline_supervisions(index: int, process_group: str):
# Every demo app has three checkpoints and the first+second checkpoints are used for deadline supervision
sourceCpIndex = index * 3
targetCpIndex = sourceCpIndex + 1
return (
"""
{
"ruleContextKey": "DeadlineSupervision"""
+ str(index)
+ """",
"maxDeadline": 80.0,
"minDeadline": 40.0,
"checkpointTransition": {
"refSourceCPIndex": """
+ str(sourceCpIndex)
+ """,
"refTargetCPIndex": """
+ str(targetCpIndex)
+ """
},
"refProcessIndices": ["""
+ str(index)
+ '''],
"refProcessGroupStates": [
{
"identifier": "'''
+ process_group
+ """/Startup"
}
]
}
"""
)


def get_logical_supervisions(index: int, process_group: str):
# Every demo app has three checkpoints and all three checkpoints in sequence are used for logical supervision
startCpIndex = index * 3
return (
"""
{
"ruleContextKey": "LogicalSupervision"""
+ str(index)
+ """",
"checkpoints": [
{
"refCheckPointIndex": """
+ str(startCpIndex)
+ """,
"isInitial": true,
"isFinal": false
},
{
"refCheckPointIndex": """
+ str(startCpIndex + 1)
+ """,
"isInitial": false,
"isFinal": false
},
{
"refCheckPointIndex": """
+ str(startCpIndex + 2)
+ """,
"isInitial": false,
"isFinal": true
}],
"transitions": [{
"checkpointSourceIdx": 0,
"checkpointTargetIdx": 1
},{
"checkpointSourceIdx": 1,
"checkpointTargetIdx": 2
}],
"refProcessIndices": ["""
+ str(index)
+ '''],
"refProcessGroupStates": [
{
"identifier": "'''
+ process_group
+ """/Startup"
}
]
}
"""
)


def get_local_supervisions(index: int):
return (
"""
Expand Down Expand Up @@ -316,8 +228,6 @@ def gen_health_monitor_cfg_for_process_group(
monitorInterfaces = []
checkpoints = []
hmAliveSupervisions = []
hmDeadlineSupervisions = []
hmLogicalSupervisions = []
hmLocalSupervisions = []
hmGlobalSupervision = []
hmRecoveryNotifications = []
Expand All @@ -335,12 +245,6 @@ def gen_health_monitor_cfg_for_process_group(
hmAliveSupervisions.append(
json.loads(get_alive_supervisions(process_index, process_group))
)
# hmDeadlineSupervisions.append(
# json.loads(get_deadline_supervisions(process_index, process_group))
# )
# hmLogicalSupervisions.append(
# json.loads(get_logical_supervisions(process_index, process_group))
# )
hmLocalSupervisions.append(json.loads(get_local_supervisions(process_index)))

hmGlobalSupervision.append(
Expand All @@ -360,8 +264,6 @@ def gen_health_monitor_cfg_for_process_group(
config["hmMonitorInterface"].extend(monitorInterfaces)
config["hmSupervisionCheckpoint"].extend(checkpoints)
config["hmAliveSupervision"].extend(hmAliveSupervisions)
config["hmDeadlineSupervision"].extend(hmDeadlineSupervisions)
config["hmLogicalSupervision"].extend(hmLogicalSupervisions)
config["hmLocalSupervision"].extend(hmLocalSupervisions)
config["hmGlobalSupervision"].extend(hmGlobalSupervision)
config["hmRecoveryNotification"].extend(hmRecoveryNotifications)
Expand Down
20 changes: 8 additions & 12 deletions examples/control_application/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,12 @@ cc_binary(
"control_app_cli.cpp",
],
copts = select({
"//config:build_qnx8": [],
"//config:x86_64-qnx": [],
"//conditions:default": ["-pthread"],
"@platforms//os:qnx": [],
"@platforms//os:linux": ["-pthread"],
}),
linkopts = select({
"//config:build_qnx8": [],
"//config:x86_64-qnx": [],
"//conditions:default": [
"@platforms//os:qnx": [],
"@platforms//os:linux": [
"-lpthread",
"-lrt",
],
Expand All @@ -42,14 +40,12 @@ cc_binary(
"control_daemon.cpp",
],
copts = select({
"//config:build_qnx8": [],
"//config:x86_64-qnx": [],
"//conditions:default": ["-pthread"],
"@platforms//os:qnx": [],
"@platforms//os:linux": ["-pthread"],
}),
linkopts = select({
"//config:build_qnx8": [],
"//config:x86_64-qnx": [],
"//conditions:default": [
"@platforms//os:qnx": [],
"@platforms//os:linux": [
"-lpthread",
"-lrt",
],
Expand Down
10 changes: 4 additions & 6 deletions examples/cpp_lifecycle_app/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,12 @@ cc_binary(
"main.cpp",
],
copts = select({
"//config:build_qnx8": [],
"//config:x86_64-qnx": [],
"//conditions:default": ["-pthread"],
"@platforms//os:qnx": [],
"@platforms//os:linux": ["-pthread"],
}),
linkopts = select({
"//config:build_qnx8": [],
"//config:x86_64-qnx": [],
"//conditions:default": ["-lpthread"],
"@platforms//os:qnx": [],
"@platforms//os:linux": ["-lpthread"],
}),
visibility = ["//visibility:public"],
deps = [
Expand Down
4 changes: 2 additions & 2 deletions examples/cpp_supervised_app/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,13 @@ cc_binary(
],
copts = select({
"@platforms//os:qnx": [],
"//conditions:default": ["-pthread"],
"@platforms//os:linux": [],
}),
linkopts = select({
"@platforms//os:qnx": [
"-lsocket",
],
"//conditions:default": [
"@platforms//os:linux": [
"-lpthread",
"-lrt",
],
Expand Down
Binary file removed examples/demo_recording.mp4
Binary file not shown.
Binary file removed examples/demo_setup1.png
Binary file not shown.
Binary file removed examples/demo_setup2.png
Binary file not shown.
3 changes: 1 addition & 2 deletions examples/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ file_exists() {
fi
}


LM_BINARY="$PWD/../bazel-bin/src/launch_manager_daemon/launch_manager"
DEMO_APP_BINARY="$PWD/../bazel-bin/examples/cpp_supervised_app/cpp_supervised_app"
DEMO_APP_WO_HM_BINARY="$PWD/../bazel-bin/examples/cpp_lifecycle_app/cpp_lifecycle_app"
Expand All @@ -41,7 +40,7 @@ file_exists $CONTROL_CLI_BINARY
NUMBER_OF_CPP_PROCESSES_PER_PROCESS_GROUP=1
NUMBER_OF_RUST_PROCESSES_PER_PROCESS_GROUP=1
NUMBER_OF_NON_SUPERVISED_CPP_PROCESSES_PER_PROCESS_GROUP=1
PROCESS_GROUPS="--process_groups MainPG"
PROCESS_GROUPS="--process_groups MainPG ProcessGroup1"

rm -rf tmp
rm -rf config/tmp
Expand Down
2 changes: 1 addition & 1 deletion examples/rust_supervised_app/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ rust_binary(
"@platforms//os:qnx": [
"-Clink-arg=-lc++",
],
"//conditions:default": [
"@platforms//os:linux": [
"-Clink-arg=-lrt",
"-Clink-arg=-lstdc++",
],
Expand Down
14 changes: 11 additions & 3 deletions externals/ipc_dropin/include/ipc_dropin/socket.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,11 @@ namespace ipc_dropin
ReturnCode create(const char *name, mode_t mode)
{
name_ = name;
fd_ = shm_open(name, O_CREAT | O_RDWR | O_CLOEXEC, mode);
if(name_.size() > 0 && name_[0] != '/') {
name_ = "/" + name_;
}

fd_ = shm_open(name_.c_str(), O_CREAT | O_RDWR | O_CLOEXEC, mode);
if (fd_ < 0)
{
if (errno == EACCES)
Expand Down Expand Up @@ -70,7 +74,11 @@ namespace ipc_dropin
ReturnCode connect(const char *name) noexcept
{
name_ = name;
fd_ = shm_open(name, O_RDWR | O_CLOEXEC, 0);
if(name_.size() > 0 && name_[0] != '/') {
name_ = "/" + name_;
}

fd_ = shm_open(name_.c_str(), O_RDWR | O_CLOEXEC, 0);
if (fd_ < 0)
{
if (errno == EACCES)
Expand Down Expand Up @@ -216,4 +224,4 @@ namespace ipc_dropin

}

#endif
#endif
4 changes: 2 additions & 2 deletions src/health_monitoring_lib/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ rust_test(
"@platforms//os:qnx": [
"-Clink-arg=-lc++",
],
"//conditions:default": [
"@platforms//os:linux": [
"-Clink-arg=-lrt",
"-Clink-arg=-lstdc++",
],
Expand All @@ -124,7 +124,7 @@ cc_gtest_unit_test(
],
linkopts = select({
"@platforms//os:qnx": ["-lsocket"],
"//conditions:default": [],
"@platforms//os:linux": [],
}),
deps = [
":health_monitoring_lib_cc_stub_supervisor",
Expand Down
11 changes: 8 additions & 3 deletions src/launch_manager_daemon/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,12 @@
# *******************************************************************************
load("//config:common_cc.bzl", "cc_binary_with_common_opts", "cc_library_with_common_opts")

filegroup(
name = "lm_flatcfg_fbs",
srcs = ["config/lm_flatcfg.fbs"],
visibility = ["//visibility:public"],
)

cc_library(
name = "config",
hdrs = ["config/lm_flatcfg_generated.h"],
Expand All @@ -29,9 +35,8 @@ cc_binary_with_common_opts(
),
includes = ["src/"],
linkopts = select({
"//config:x86_64-qnx": ["-lsecpol"],
"//config:build_qnx8": ["-lsecpol"],
"//conditions:default": ["-lpthread"],
"@platforms//os:qnx": ["-lsecpol"],
"@platforms//os:linux": ["-lpthread"],
}),
visibility = ["//visibility:public"],
deps = [
Expand Down
12 changes: 2 additions & 10 deletions src/launch_manager_daemon/common/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -57,23 +57,15 @@ cc_library(
cc_library(
name = "osal",
srcs = select({
"//config:x86_64-qnx": glob(
"@platforms//os:qnx": glob(
[
"src/internal/osal/**/*.cpp",
],
exclude = [
"src/internal/osal/linux/**",
],
),
"//config:build_qnx8": glob(
[
"src/internal/osal/**/*.cpp",
],
exclude = [
"src/internal/osal/linux/**",
],
),
"//conditions:default": glob(
"@platforms//os:linux": glob(
[
"src/internal/osal/**/*.cpp",
],
Expand Down
Loading
Loading