Skip to contentSkip to conversation

ti-ipc: Add systemd startup script

PATCH Superseded Sam Nelson 2 participants 2 messages Sep 7, 2018 – Sep 10, 2018

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

Sam Nelson

author
#0 lore raw

PATCH 1/1 ti-ipc: Add systemd startup script

With systemd enabled, it is better to add the proper systemd script instead of legacy init.d script.

---
 recipes-ti/ipc/ti-ipc/tiipclad-daemon.service | 11 +++++++++++
 recipes-ti/ipc/ti-ipc_git.bb                  | 21 +++++++++++++++++----
 2 files changed, 28 insertions(+), 4 deletions(-)
 create mode 100644 recipes-ti/ipc/ti-ipc/tiipclad-daemon.service
recipes-ti/ipc/ti-ipc/tiipclad-daemon.service new file +11 -0
new file mode 100644
index 0000000..7c09c7d
@@ -0,0 +1,11 @@
+[Unit]
+Description=TI IPC Daemon
+
+[Service]
+Type=forking
+PIDFile=/var/run/tiipclad.pid
+ExecStart=/usr/bin/__LAD_DAEMON__ -g -l lad.txt
+PIDFile=/var/run/tiipclad.pid
+
+[Install]
+WantedBy=basic.target
recipes-ti/ipc/ti-ipc_git.bb +17 -4
index 23b8d94..8b3ac91 100644
@@ -4,12 +4,13 @@ HOMEPAGE="http://processors.wiki.ti.com/index.php/Category:IPC"
 require ti-ipc.inc
 require ti-ipc-common.inc
 
-PR = "${INC_PR}.1"
+PR = "${INC_PR}.2"
 
 DEPENDS += "virtual/kernel"
 
 SRC_URI += "file://tiipclad-daemon.sh \
             file://omap_remoteproc.conf \
+            file://tiipclad-daemon.service \
             file://0001-Add-kernel-build-dir.patch \
            "
 
@@ -23,11 +24,13 @@ DAEMON_k2g = "lad_66ak2g"
 DAEMON_omapl138 = "lad_omapl138"
 DAEMON_k3 = "lad_am65xx"
 
-inherit autotools-brokensep pkgconfig update-rc.d
+inherit autotools-brokensep pkgconfig update-rc.d systemd
 
 INITSCRIPT_NAME = "tiipclad-daemon.sh"
 INITSCRIPT_PARAMS = "defaults 10"
 
+SYSTEMD_SERVICE_${PN} = "tiipclad-daemon.service"
+
 EXTRA_OECONF += "PLATFORM=${PLATFORM} KERNEL_INSTALL_DIR=${STAGING_KERNEL_DIR} KERNEL_BUILD_DIR=${STAGING_KERNEL_BUILDDIR}"
 
 do_compile[depends] += "virtual/kernel:do_shared_workdir"
@@ -40,10 +43,20 @@ do_configure() {
 do_install_append() {
     install -d ${D}${sysconfdir}/init.d/
 
-    # Modify the tiipclad-daemon.sh script to point to the right
+    # Modify the startup scripts to point to the right
     # lad daemon executable.
     sed -i -e "s/__LAD_DAEMON__/${DAEMON}/" ${WORKDIR}/tiipclad-daemon.sh
-    install -c -m 755 ${WORKDIR}/tiipclad-daemon.sh ${D}${sysconfdir}/init.d/${INITSCRIPT_NAME}
+    sed -i -e "s/__LAD_DAEMON__/${DAEMON}/" ${WORKDIR}/tiipclad-daemon.service
+
+    systemd_enabled=${@bb.utils.contains('DISTRO_FEATURES', 'systemd', '1', '0', d)}
+    if [ ${systemd_enabled} -eq 1 ]
+    then
+        install -d ${D}${systemd_system_unitdir}
+        install -m 0644 ${WORKDIR}/tiipclad-daemon.service ${D}${systemd_system_unitdir}
+    else
+        install -d ${D}${sysconfdir}/init.d/
+        install -c -m 755 ${S}/scripts/tiipclad-daemon.sh ${D}${sysconfdir}/init.d/${INITSCRIPT_NAME}
+    fi
 }
 
 do_install_append_dra7xx() {
Signature · 1 line
1.9.1
#1 lore raw

Sam,

On Friday night Suman and I were debugging issues with this new systemd service file.

First of all, you hahve PIDFile entry twice.
Second, this entry is recommended, but not required. But if specified, systemd expects the daemon to create that PID file and if the file is not there after a minute or so, it kills the daemon.

Everything seems to work just fine w/o any PIDFile entries.

Please send v2 of the patch - I'll drop it from the next branch.

Quoted 92 lines · Sam Nelson

With systemd enabled, it is better to add the proper systemd script instead of legacy init.d script.

---
 recipes-ti/ipc/ti-ipc/tiipclad-daemon.service | 11 +++++++++++
 recipes-ti/ipc/ti-ipc_git.bb                  | 21 +++++++++++++++++----
 2 files changed, 28 insertions(+), 4 deletions(-)
 create mode 100644 recipes-ti/ipc/ti-ipc/tiipclad-daemon.service
recipes-ti/ipc/ti-ipc/tiipclad-daemon.service new file +11 -0
new file mode 100644
index 0000000..7c09c7d
@@ -0,0 +1,11 @@
+[Unit]
+Description=TI IPC Daemon
+
+[Service]
+Type=forking
+PIDFile=/var/run/tiipclad.pid
+ExecStart=/usr/bin/__LAD_DAEMON__ -g -l lad.txt
+PIDFile=/var/run/tiipclad.pid
+
+[Install]
+WantedBy=basic.target
recipes-ti/ipc/ti-ipc_git.bb +17 -4
index 23b8d94..8b3ac91 100644
@@ -4,12 +4,13 @@ HOMEPAGE="http://processors.wiki.ti.com/index.php/Category:IPC"
 require ti-ipc.inc
 require ti-ipc-common.inc
 
-PR = "${INC_PR}.1"
+PR = "${INC_PR}.2"
 
 DEPENDS += "virtual/kernel"
 
 SRC_URI += "file://tiipclad-daemon.sh \
             file://omap_remoteproc.conf \
+            file://tiipclad-daemon.service \
             file://0001-Add-kernel-build-dir.patch \
            "
 
@@ -23,11 +24,13 @@ DAEMON_k2g = "lad_66ak2g"
 DAEMON_omapl138 = "lad_omapl138"
 DAEMON_k3 = "lad_am65xx"
 
-inherit autotools-brokensep pkgconfig update-rc.d
+inherit autotools-brokensep pkgconfig update-rc.d systemd
 
 INITSCRIPT_NAME = "tiipclad-daemon.sh"
 INITSCRIPT_PARAMS = "defaults 10"
 
+SYSTEMD_SERVICE_${PN} = "tiipclad-daemon.service"
+
 EXTRA_OECONF += "PLATFORM=${PLATFORM} KERNEL_INSTALL_DIR=${STAGING_KERNEL_DIR} KERNEL_BUILD_DIR=${STAGING_KERNEL_BUILDDIR}"
 
 do_compile[depends] += "virtual/kernel:do_shared_workdir"
@@ -40,10 +43,20 @@ do_configure() {
 do_install_append() {
     install -d ${D}${sysconfdir}/init.d/
 
-    # Modify the tiipclad-daemon.sh script to point to the right
+    # Modify the startup scripts to point to the right
     # lad daemon executable.
     sed -i -e "s/__LAD_DAEMON__/${DAEMON}/" ${WORKDIR}/tiipclad-daemon.sh
-    install -c -m 755 ${WORKDIR}/tiipclad-daemon.sh ${D}${sysconfdir}/init.d/${INITSCRIPT_NAME}
+    sed -i -e "s/__LAD_DAEMON__/${DAEMON}/" ${WORKDIR}/tiipclad-daemon.service
+
+    systemd_enabled=${@bb.utils.contains('DISTRO_FEATURES', 'systemd', '1', '0', d)}
+    if [ ${systemd_enabled} -eq 1 ]
+    then
+        install -d ${D}${systemd_system_unitdir}
+        install -m 0644 ${WORKDIR}/tiipclad-daemon.service ${D}${systemd_system_unitdir}
+    else
+        install -d ${D}${sysconfdir}/init.d/
+        install -c -m 755 ${S}/scripts/tiipclad-daemon.sh ${D}${sysconfdir}/init.d/${INITSCRIPT_NAME}
+    fi
 }
 
 do_install_append_dra7xx() {
Signature · 7 lines
1.9.1

-- 
_______________________________________________
meta-ti mailing list
[email protected]
https://lists.yoctoproject.org/listinfo/meta-ti