diff --git a/recipes-openharmony/openharmony/files/hiview.service b/recipes-openharmony/openharmony/files/hiview.service new file mode 100644 index 0000000000000000000000000000000000000000..16205d9575ce2aac595b6e40e40d11fad1718bd2 --- /dev/null +++ b/recipes-openharmony/openharmony/files/hiview.service @@ -0,0 +1,20 @@ +[Unit] +Description=OpenHarmony hiview service (SA: 1201 1202) +Wants=param.service +After=param.service +Requires=samgr.service +After=samgr.service +Wants=hilogd.service +After=hilogd.service + +[Service] +Type=notify +ExecStartPre=!install -o system -g system -m 0755 -d /run/openharmony/hiview +User=system +Group=system +SupplementaryGroups=log +LimitNICE=40 +ExecStart=/usr/bin/hiview + +#[Install] +#WantedBy=multi-user.target diff --git a/recipes-openharmony/openharmony/openharmony-standard-3.0/hisysevent-socket-path.patch b/recipes-openharmony/openharmony/openharmony-standard-3.0/hisysevent-socket-path.patch new file mode 100644 index 0000000000000000000000000000000000000000..5060c28ba0cd2a610747c3dbfe3a15b63cdaf500 --- /dev/null +++ b/recipes-openharmony/openharmony/openharmony-standard-3.0/hisysevent-socket-path.patch @@ -0,0 +1,17 @@ +diff --git a/interfaces/native/innerkits/hisysevent.cpp b/interfaces/native/innerkits/hisysevent.cpp +index 473e84241605..2309158193fe 100644 +--- a/interfaces/native/innerkits/hisysevent.cpp ++++ b/interfaces/native/innerkits/hisysevent.cpp +@@ -49,11 +49,7 @@ static constexpr unsigned int MAX_PARAM_NUMBER = 128; + static constexpr unsigned int MAX_STRING_LENGTH = 256 * 1024; + static constexpr unsigned int MAX_JSON_SIZE = 384 * 1024; + +-#ifdef USE_MUSL +-static constexpr char SOCKET_FILE_DIR[] = "/dev/unix/socket/hisysevent"; +-#else +-static constexpr char SOCKET_FILE_DIR[] = "/dev/socket/hisysevent"; +-#endif ++static constexpr char SOCKET_FILE_DIR[] = "/run/openharmony/hiview/hisysevent"; + + static constexpr HiLogLabel LABEL = { LOG_CORE, 0xD002D08, "HISYSEVENT" }; + diff --git a/recipes-openharmony/openharmony/openharmony-standard-3.0/hiview-sd-notify.patch b/recipes-openharmony/openharmony/openharmony-standard-3.0/hiview-sd-notify.patch new file mode 100644 index 0000000000000000000000000000000000000000..3bfd3155e4f4e785c44b76ccade8b9bf247b96b7 --- /dev/null +++ b/recipes-openharmony/openharmony/openharmony-standard-3.0/hiview-sd-notify.patch @@ -0,0 +1,33 @@ +diff --git a/adapter/service/idl/BUILD.gn b/adapter/service/idl/BUILD.gn +index 1120463e2264..320a8809472c 100644 +--- a/adapter/service/idl/BUILD.gn ++++ b/adapter/service/idl/BUILD.gn +@@ -43,6 +43,7 @@ ohos_source_set("hiview_service_impl") { + "$hiview_base:hiviewbase", + "//utils/native/base:utils", + ] ++ libs = [ "systemd"] + + external_deps = [ + "hilog_native:libhilog", +diff --git a/adapter/service/idl/src/hiview_service_ability.cpp b/adapter/service/idl/src/hiview_service_ability.cpp +index 757c0dbfd575..a2f1cc58845e 100644 +--- a/adapter/service/idl/src/hiview_service_ability.cpp ++++ b/adapter/service/idl/src/hiview_service_ability.cpp +@@ -18,6 +18,8 @@ + #include <cstdio> + #include <unistd.h> + ++#include <systemd/sd-daemon.h> ++ + #include "system_ability_definition.h" + #include "iservice_registry.h" + #include "ipc_skeleton.h" +@@ -89,6 +91,7 @@ void HiviewServiceAbility::StartServiceAbility(int sleepS) + if (ret == false) { + HIVIEW_LOGE("AddDeathRecipient == false"); + } ++ sd_notify(0, "READY=1"); + } + + void HiviewServiceAbility::StartService(HiviewService *service) diff --git a/recipes-openharmony/openharmony/openharmony-standard-3.0/hiview-socket-path.patch b/recipes-openharmony/openharmony/openharmony-standard-3.0/hiview-socket-path.patch new file mode 100644 index 0000000000000000000000000000000000000000..ce68d9702ba94e771ecf863e189d6ade4a296ed1 --- /dev/null +++ b/recipes-openharmony/openharmony/openharmony-standard-3.0/hiview-socket-path.patch @@ -0,0 +1,17 @@ +diff --git a/core/event_server.cpp b/core/event_server.cpp +index 438b01ed59ea..081ecdcd9936 100644 +--- a/core/event_server.cpp ++++ b/core/event_server.cpp +@@ -34,11 +34,7 @@ extern "C" { + #include "logger.h" + #include "socket_util.h" + +-#ifdef USE_MUSL +-#define SOCKET_FILE_DIR "/dev/unix/socket/hisysevent" +-#else +-#define SOCKET_FILE_DIR "/dev/socket/hisysevent" +-#endif ++#define SOCKET_FILE_DIR "/run/openharmony/hiview/hisysevent" + + namespace OHOS { + namespace HiviewDFX { diff --git a/recipes-openharmony/openharmony/openharmony-standard_3.0.bb b/recipes-openharmony/openharmony/openharmony-standard_3.0.bb index 2c0d3b7f4585f1f55ec7a83b639db22ff6d1cf7c..c50b3ed632d555a7c3887ce6ebd9a8b9cfd954e3 100644 --- a/recipes-openharmony/openharmony/openharmony-standard_3.0.bb +++ b/recipes-openharmony/openharmony/openharmony-standard_3.0.bb @@ -87,6 +87,10 @@ SRC_URI += "file://base_hiviewdfx_hiview-libfaultlogger-static.patch;patchdir=${ SRC_URI += "file://faultloggerd-socket-path.patch;patchdir=${S}/base/hiviewdfx/faultloggerd" SRC_URI += "file://faultloggerd-sd-notify.patch;patchdir=${S}/base/hiviewdfx/faultloggerd" +SRC_URI += "file://hiview-sd-notify.patch;patchdir=${S}/base/hiviewdfx/hiview" +SRC_URI += "file://hiview-socket-path.patch;patchdir=${S}/base/hiviewdfx/hiview" +SRC_URI += "file://hisysevent-socket-path.patch;patchdir=${S}/base/hiviewdfx/hisysevent" + # Patch to allow /system/profile and /system/usr to be symlinks to /usr/lib/openharmony SRC_URI += "file://foundation_distributedschedule_safwk-slash-system-symlink.patch;patchdir=${S}/foundation/distributedschedule/safwk" @@ -1672,11 +1676,20 @@ RDEPENDS:${PN} += "${PN}-thirdparty-ejdb" # //base/hiviewdfx/hiview PACKAGES =+ "${PN}-hiview" +SYSTEMD_PACKAGES += "${PN}-hiview" +SYSTEMD_SERVICE:${PN}-hiview = "hiview.service" +SRC_URI += "file://hiview.service" +do_install:append() { + install -d ${D}/${systemd_unitdir}/system + install -m 644 -t ${D}${systemd_unitdir}/system/ \ + ${WORKDIR}/hiview.service + rm -f ${D}${sysconfdir}/openharmony/init/hiview.cfg +} FILES:${PN}-hiview = " \ ${bindir}/hiview \ ${libdir}/libhiviewbase*${SOLIBS} \ " -RDEPENDS:${PN}-hiview += "musl libcxx" +RDEPENDS:${PN}-hiview += "musl libcxx libsystemd" RDEPENDS:${PN}-hiview += " \ ${PN}-libutils \ ${PN}-hilog \