From 31b14ebae99f5e19137451911f2bb77fe3e693e8 Mon Sep 17 00:00:00 2001 From: Fabian Franz BSc Date: Tue, 14 May 2024 22:02:07 +0200 Subject: [PATCH 01/13] Create xlxd.service run xlxd as xlxd user (needed to be created manually) --- scripts/xlxd.service | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 scripts/xlxd.service diff --git a/scripts/xlxd.service b/scripts/xlxd.service new file mode 100644 index 00000000..cfc4bf6e --- /dev/null +++ b/scripts/xlxd.service @@ -0,0 +1,15 @@ +[Unit] +Description=XLX Reflector (XLX999) +After=network.target ambed.service + +[Service] +Type=forking +User=xlxd +Group=xlxd +AmbientCapabilities=CAP_NET_RAW +ExecStart=/usr/bin/xlxd XLX999 1.2.3.4 127.0.0.1 +Restart=on-abnormal +RestartSec=30 + +[Install] +WantedBy=multi-user.target From 2dec160aba5d6bea366e04c4d7824c939e475186 Mon Sep 17 00:00:00 2001 From: Fabian Franz BSc Date: Tue, 14 May 2024 22:05:55 +0200 Subject: [PATCH 02/13] Update xlxd.service --- scripts/xlxd.service | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/xlxd.service b/scripts/xlxd.service index cfc4bf6e..77962086 100644 --- a/scripts/xlxd.service +++ b/scripts/xlxd.service @@ -7,7 +7,7 @@ Type=forking User=xlxd Group=xlxd AmbientCapabilities=CAP_NET_RAW -ExecStart=/usr/bin/xlxd XLX999 1.2.3.4 127.0.0.1 +ExecStart=/xlxd/xlxd XLX999 1.2.3.4 127.0.0.1 Restart=on-abnormal RestartSec=30 From 890e4880594a526d12cee27e6e45683e32bece6a Mon Sep 17 00:00:00 2001 From: Fabian Franz Date: Sun, 9 Jun 2024 12:14:40 +0200 Subject: [PATCH 03/13] add possibillity to query uptime via systemd --- dashboard/pgs/class.reflector.php | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/dashboard/pgs/class.reflector.php b/dashboard/pgs/class.reflector.php index 099599c8..9bf1f8c7 100755 --- a/dashboard/pgs/class.reflector.php +++ b/dashboard/pgs/class.reflector.php @@ -109,6 +109,18 @@ public function SetPIDFile($ProcessIDFile) { else { $this->ProcessIDFile = null; $this->ServiceUptime = null; + + exec('/usr/bin/systemctl show --property=ActiveEnterTimestamp xlxd.service', $out, $code); + if ($code == 0) { + if (is_array($out) && count($out) > 0) { + $out = $out[0]; + } + if (is_string($out)) { + $out = explode('=', $out, 2)[1]; + $out = strtotime($out); + $this->ServiceUptime = time() - $out; + } + } } } From bad324fdcfcb4711b0d9af3283e8ebd2228d1948 Mon Sep 17 00:00:00 2001 From: Fabian Franz Date: Sun, 9 Jun 2024 12:35:50 +0200 Subject: [PATCH 04/13] add xlxapi-update --- scripts/xlxapi-update | 3 +++ scripts/xlxapi-update.service | 9 +++++++++ scripts/xlxapi-update.timer | 9 +++++++++ 3 files changed, 21 insertions(+) create mode 100755 scripts/xlxapi-update create mode 100644 scripts/xlxapi-update.service create mode 100644 scripts/xlxapi-update.timer diff --git a/scripts/xlxapi-update b/scripts/xlxapi-update new file mode 100755 index 00000000..ff45d135 --- /dev/null +++ b/scripts/xlxapi-update @@ -0,0 +1,3 @@ +#!/bin/bash +/usr/bin/wget -q -O- http://localhost/index.php?callhome=1 > /dev/null + diff --git a/scripts/xlxapi-update.service b/scripts/xlxapi-update.service new file mode 100644 index 00000000..9e5aa85b --- /dev/null +++ b/scripts/xlxapi-update.service @@ -0,0 +1,9 @@ +[Unit] +Description=XLX API Service +After=network.target + +[Service] +Type=simple +ExecStart=/usr/bin/xlxapi-update + + diff --git a/scripts/xlxapi-update.timer b/scripts/xlxapi-update.timer new file mode 100644 index 00000000..73570ae8 --- /dev/null +++ b/scripts/xlxapi-update.timer @@ -0,0 +1,9 @@ +[Unit] +Description=Run xlx api call every day (if nobody opens the dashboard) + +[Timer] +OnCalendar=*-*-* 1:0:0 +Unit=xlxapi-update.service + +[Install] +WantedBy=multi-user.target From bbe62c9ca918d193848b1bbc731547de8f70480b Mon Sep 17 00:00:00 2001 From: Fabian Franz Date: Fri, 19 Jul 2024 13:37:47 +0200 Subject: [PATCH 05/13] Make ambed.service systemd native. This allows to make xlx start when ambed.service is fully started up. --- ambed/cambeserver.cpp | 2 ++ ambed/cvocodecs.cpp | 3 +++ ambed/makefile | 2 +- scripts/ambed.service | 2 +- 4 files changed, 7 insertions(+), 2 deletions(-) diff --git a/ambed/cambeserver.cpp b/ambed/cambeserver.cpp index 9ce1da23..ce25b8bf 100644 --- a/ambed/cambeserver.cpp +++ b/ambed/cambeserver.cpp @@ -27,6 +27,7 @@ #include "ccontroller.h" #include "cvocodecs.h" #include "cambeserver.h" +#include //////////////////////////////////////////////////////////////////////////////////////// @@ -81,6 +82,7 @@ bool CAmbeServer::Start(void) { // m_pThread = new std::thread(CAmbeServer::Thread, this); + sd_notify(0, "READY=1"); } // done diff --git a/ambed/cvocodecs.cpp b/ambed/cvocodecs.cpp index c9e4643a..eee73746 100644 --- a/ambed/cvocodecs.cpp +++ b/ambed/cvocodecs.cpp @@ -25,6 +25,7 @@ #include "main.h" #include #include "cvocodecs.h" +#include //////////////////////////////////////////////////////////////////////////////////////// // global object @@ -243,10 +244,12 @@ bool CVocodecs::Init(void) if ( ok ) { std::cout << "Codec interfaces initialized successfully : " << iNbCh << " channels available" << std::endl; + sd_notifyf(0, "STATUS=Codec interfaces initialized successfully : %i channels available", iNbCh); } else { std::cout << "At least one codec interfaces failed to initialize : " << iNbCh << " channels availables" << std::endl; + sd_notifyf(0, "At least one codec interfaces failed to initialize : %i channels availables", iNbCh); } // done return ok; diff --git a/ambed/makefile b/ambed/makefile index c556a285..fcfd5700 100644 --- a/ambed/makefile +++ b/ambed/makefile @@ -8,7 +8,7 @@ EXECUTABLE=ambed all: $(SOURCES) $(EXECUTABLE) $(EXECUTABLE): $(OBJECTS) - $(CC) $(LDFLAGS) $(OBJECTS) -lftd2xx -Wl,-rpath,/usr/local/lib -o $@ + $(CC) $(LDFLAGS) $(OBJECTS) -lftd2xx -I/usr/src/libftd2xx-x86_64-1.4.27 -Wl,-rpath,/usr/local/lib -lsystemd -o $@ .cpp.o: $(CC) $(CFLAGS) $< -o $@ diff --git a/scripts/ambed.service b/scripts/ambed.service index 8332fae8..42786da5 100644 --- a/scripts/ambed.service +++ b/scripts/ambed.service @@ -3,7 +3,7 @@ Description=AMBE Transcoder Daemon After=network.target [Service] -Type=simple +Type=notify User=root Group=root ExecStartPre=-/sbin/rmmod ftdi_sio From bf8b205fca09250daf14b0f8215551cef5c70d96 Mon Sep 17 00:00:00 2001 From: Fabian Franz Date: Fri, 19 Jul 2024 16:13:23 +0200 Subject: [PATCH 06/13] Make xlxd.service systemd native. --- scripts/xlxd.service | 2 +- src/creflector.cpp | 2 ++ src/makefile | 2 +- 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/scripts/xlxd.service b/scripts/xlxd.service index 77962086..ab43b694 100644 --- a/scripts/xlxd.service +++ b/scripts/xlxd.service @@ -3,7 +3,7 @@ Description=XLX Reflector (XLX999) After=network.target ambed.service [Service] -Type=forking +Type=notify User=xlxd Group=xlxd AmbientCapabilities=CAP_NET_RAW diff --git a/src/creflector.cpp b/src/creflector.cpp index a813df96..8431203f 100644 --- a/src/creflector.cpp +++ b/src/creflector.cpp @@ -31,6 +31,7 @@ #include "ctranscoder.h" #include "cysfnodedirfile.h" #include "cysfnodedirhttp.h" +#include //////////////////////////////////////////////////////////////////////////////////////// // constructor @@ -132,6 +133,7 @@ bool CReflector::Start(void) #ifdef JSON_MONITOR m_JsonReportThread = new std::thread(CReflector::JsonReportThread, this); #endif + sd_notify(0, "READY=1"); } else { diff --git a/src/makefile b/src/makefile index 2d7b5875..89304c9d 100644 --- a/src/makefile +++ b/src/makefile @@ -1,6 +1,6 @@ CC=g++ CFLAGS=-c -std=c++11 -pthread -LDFLAGS=-std=c++11 -pthread +LDFLAGS=-std=c++11 -pthread -lsystemd SOURCES=$(wildcard *.cpp) OBJECTS=$(SOURCES:.cpp=.o) EXECUTABLE=xlxd From f3529b81f750678892d8602dd3d1fc378b17a47c Mon Sep 17 00:00:00 2001 From: Fabian Franz BSc Date: Fri, 16 Aug 2024 23:02:33 +0200 Subject: [PATCH 07/13] Update ambed/cvocodecs.cpp --- ambed/cvocodecs.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ambed/cvocodecs.cpp b/ambed/cvocodecs.cpp index eee73746..d3fe698c 100644 --- a/ambed/cvocodecs.cpp +++ b/ambed/cvocodecs.cpp @@ -249,7 +249,7 @@ bool CVocodecs::Init(void) else { std::cout << "At least one codec interfaces failed to initialize : " << iNbCh << " channels availables" << std::endl; - sd_notifyf(0, "At least one codec interfaces failed to initialize : %i channels availables", iNbCh); + sd_notifyf(0, "STATUS=At least one codec interfaces failed to initialize : %i channels availables", iNbCh); } // done return ok; From 48171abc6108e863814bf1ecc459526599262416 Mon Sep 17 00:00:00 2001 From: Fabian Franz BSc Date: Fri, 16 Aug 2024 23:03:21 +0200 Subject: [PATCH 08/13] revert accidentally committed line --- ambed/makefile | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/ambed/makefile b/ambed/makefile index fcfd5700..ce8912db 100644 --- a/ambed/makefile +++ b/ambed/makefile @@ -8,7 +8,8 @@ EXECUTABLE=ambed all: $(SOURCES) $(EXECUTABLE) $(EXECUTABLE): $(OBJECTS) - $(CC) $(LDFLAGS) $(OBJECTS) -lftd2xx -I/usr/src/libftd2xx-x86_64-1.4.27 -Wl,-rpath,/usr/local/lib -lsystemd -o $@ + $(CC) $(LDFLAGS) $(OBJECTS) -lftd2xx -Wl,-rpath,/usr/local/lib -lsystemd -o $@ + .cpp.o: $(CC) $(CFLAGS) $< -o $@ From 2aebbdea84a589180a9d8e8addc4ad68ef666a43 Mon Sep 17 00:00:00 2001 From: Fabian Franz BSc Date: Sat, 14 Sep 2024 18:23:34 +0200 Subject: [PATCH 09/13] Update xlxd.service starts xlxd after interface has its ip --- scripts/xlxd.service | 1 + 1 file changed, 1 insertion(+) diff --git a/scripts/xlxd.service b/scripts/xlxd.service index ab43b694..362aece8 100644 --- a/scripts/xlxd.service +++ b/scripts/xlxd.service @@ -1,6 +1,7 @@ [Unit] Description=XLX Reflector (XLX999) After=network.target ambed.service +Requires=network-online.target [Service] Type=notify From 51fa189119420a7c308a42fb763bd5b1fe25e3bc Mon Sep 17 00:00:00 2001 From: Fabian Franz BSc Date: Sat, 14 Sep 2024 18:25:06 +0200 Subject: [PATCH 10/13] Update ambed.service start ambed after we have an IP address --- scripts/ambed.service | 1 + 1 file changed, 1 insertion(+) diff --git a/scripts/ambed.service b/scripts/ambed.service index 42786da5..2ee0895b 100644 --- a/scripts/ambed.service +++ b/scripts/ambed.service @@ -1,6 +1,7 @@ [Unit] Description=AMBE Transcoder Daemon After=network.target +Requires=network-online.target [Service] Type=notify From af3fca5111290070cd5001a39ef3bcad117d592f Mon Sep 17 00:00:00 2001 From: Fabian Franz BSc Date: Wed, 2 Oct 2024 11:26:20 +0200 Subject: [PATCH 11/13] Create ambedwatchdog.timer --- scripts/ambedwatchdog.timer | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 scripts/ambedwatchdog.timer diff --git a/scripts/ambedwatchdog.timer b/scripts/ambedwatchdog.timer new file mode 100644 index 00000000..6ceb90f7 --- /dev/null +++ b/scripts/ambedwatchdog.timer @@ -0,0 +1,10 @@ +[Unit] +Description=Contiously monitor ambed if it crashes +Requires=xlxd.service ambed.service + +[Timer] +OnCalendar=*-*-* *:*:0/5 +Unit=ambedwatchdog.service + +[Install] +WantedBy=multi-user.target From 44893d2f211ef472af7cb277a413e13f2e3e3a66 Mon Sep 17 00:00:00 2001 From: Fabian Franz BSc Date: Wed, 2 Oct 2024 11:27:07 +0200 Subject: [PATCH 12/13] Create ambedwatchdog.service --- scripts/ambedwatchdog.service | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 scripts/ambedwatchdog.service diff --git a/scripts/ambedwatchdog.service b/scripts/ambedwatchdog.service new file mode 100644 index 00000000..83a898f4 --- /dev/null +++ b/scripts/ambedwatchdog.service @@ -0,0 +1,7 @@ +[Unit] +Description=Check ambedwatchdog +After=network.target + +[Service] +Type=simple +ExecStart=/usr/bin/ambedwatchdog From b5a84dc4a655b4f9ed89ac0839dcc4cd24cac612 Mon Sep 17 00:00:00 2001 From: Fabian Franz BSc Date: Wed, 2 Oct 2024 11:28:05 +0200 Subject: [PATCH 13/13] Create ambedwatchdog --- scripts/ambedwatchdog | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 scripts/ambedwatchdog diff --git a/scripts/ambedwatchdog b/scripts/ambedwatchdog new file mode 100644 index 00000000..4953802c --- /dev/null +++ b/scripts/ambedwatchdog @@ -0,0 +1,5 @@ +#!/bin/sh +if journalctl -u ambed.service --since "5min ago" --grep 'Device .* is unresponsive'; then + systemctl restart ambed.service + systemctl restart xlxd.service +fi