Skip to content
Snippets Groups Projects
Commit 0eedff74 authored by Esben Haabendal's avatar Esben Haabendal
Browse files

openharmony-standard: Add sd_notify ready notification to param_service


This ensures that when used in a systemd service, other units that depend on it
will only been started when the param_service is actually ready to respond to
requests.

Signed-off-by: default avatarEsben Haabendal <esben@geanix.com>
parent 90846bea
No related branches found
No related tags found
1 merge request!109Systemd service integration and stability improvements
# SPDX-FileCopyrightText: Huawei Inc.
#
# SPDX-License-Identifier: Apache-2.0
Patch for //base/startup/init_lite of OpenHarmony 3.0 codebase
This adds sd_notify(3) ready notification to param_service for better
integration with systemd.
Signed-off-by: Esben Haabendal <esben@geanix.com>
Upstream-Status: Pending
diff --git a/services/param/BUILD.gn b/services/param/BUILD.gn
index 07e1d2784915..d8a8110f0ec6 100644
--- a/services/param/BUILD.gn
+++ b/services/param/BUILD.gn
@@ -38,6 +38,7 @@ ohos_static_library("paramservice") {
"//third_party/bounds_checking_function:libsec_static",
"//third_party/libuv:uv_static",
]
+ libs = [ "systemd" ]
part_name = "init"
subsystem_name = "startup"
}
diff --git a/services/param/service/param_service.c b/services/param/service/param_service.c
index cd5d93be3ff6..1b5bb213d257 100644
--- a/services/param/service/param_service.c
+++ b/services/param/service/param_service.c
@@ -20,6 +20,8 @@
#include <string.h>
#include <unistd.h>
+#include <systemd/sd-daemon.h>
+
#include "init_param.h"
#include "init_utils.h"
#include "param_manager.h"
@@ -252,7 +254,9 @@ int StartParamService()
PARAM_CHECK(ret == 0, return ret, "Failed to chmod %s, err %d. ", PIPE_NAME, errno);
ret = uv_listen((uv_stream_t*)&pipeServer, SOMAXCONN, OnConnection);
PARAM_CHECK(ret == 0, return ret, "Failed to uv_listen %d %s", ret, uv_err_name(ret));
+ sd_notify(0, "READY=1");
uv_run(uv_default_loop(), UV_RUN_DEFAULT);
+ sd_notify(0, "STOPPING=1");
PARAM_LOGI("Start service exit.");
return 0;
}
...@@ -19,6 +19,9 @@ DEPENDS += "bison-native" ...@@ -19,6 +19,9 @@ DEPENDS += "bison-native"
DEPENDS += "ruby-native" DEPENDS += "ruby-native"
DEPENDS += "packing-tool-native" DEPENDS += "packing-tool-native"
# We are adding sd_notify(3) calls to OpenHarmony services
DEPENDS += "systemd"
# Note: Using include instead of require to avoid parser error skipping recipe # Note: Using include instead of require to avoid parser error skipping recipe
include ${PN}-sources-${OPENHARMONY_VERSION}.inc include ${PN}-sources-${OPENHARMONY_VERSION}.inc
...@@ -65,6 +68,7 @@ SRC_URI += "file://test_xts_acts-Align-tests-list-with-mandatory-set.patch;patch ...@@ -65,6 +68,7 @@ SRC_URI += "file://test_xts_acts-Align-tests-list-with-mandatory-set.patch;patch
SRC_URI += "file://init_lite-silence-GetControlFromEnv-spam.patch;patchdir=${S}/base/startup/init_lite" SRC_URI += "file://init_lite-silence-GetControlFromEnv-spam.patch;patchdir=${S}/base/startup/init_lite"
SRC_URI += "file://param_service_standalone.patch;patchdir=${S}/base/startup/init_lite" SRC_URI += "file://param_service_standalone.patch;patchdir=${S}/base/startup/init_lite"
SRC_URI += "file://param_service-sd-notify.patch;patchdir=${S}/base/startup/init_lite"
SRC_URI += "file://param_service-Add-to-startup-l2-part.patch;patchdir=${S}/base/startup/appspawn_standard" SRC_URI += "file://param_service-Add-to-startup-l2-part.patch;patchdir=${S}/base/startup/appspawn_standard"
SRC_URI += "file://base_hiviewdfx_hiview-libfaultlogger-static.patch;patchdir=${S}/base/hiviewdfx/hiview" SRC_URI += "file://base_hiviewdfx_hiview-libfaultlogger-static.patch;patchdir=${S}/base/hiviewdfx/hiview"
...@@ -1796,7 +1800,7 @@ FILES:${PN}-param-service = " \ ...@@ -1796,7 +1800,7 @@ FILES:${PN}-param-service = " \
${bindir}/setparam \ ${bindir}/setparam \
${bindir}/param_service \ ${bindir}/param_service \
" "
RDEPENDS:${PN}-param-service += "musl libcxx" RDEPENDS:${PN}-param-service += "musl libcxx libsystemd"
RDEPENDS:${PN} += "${PN}-param-service" RDEPENDS:${PN} += "${PN}-param-service"
# Third Party Components (//third_party/*) # Third Party Components (//third_party/*)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment