This commit is contained in:
Fabian Franz BSc 2024-10-02 11:32:41 +02:00 committed by GitHub
commit eea0e854ca
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
14 changed files with 83 additions and 3 deletions

View file

@ -27,6 +27,7 @@
#include "ccontroller.h"
#include "cvocodecs.h"
#include "cambeserver.h"
#include <systemd/sd-daemon.h>
////////////////////////////////////////////////////////////////////////////////////////
@ -81,6 +82,7 @@ bool CAmbeServer::Start(void)
{
//
m_pThread = new std::thread(CAmbeServer::Thread, this);
sd_notify(0, "READY=1");
}
// done

View file

@ -25,6 +25,7 @@
#include "main.h"
#include <string.h>
#include "cvocodecs.h"
#include <systemd/sd-daemon.h>
////////////////////////////////////////////////////////////////////////////////////////
// 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, "STATUS=At least one codec interfaces failed to initialize : %i channels availables", iNbCh);
}
// done
return ok;

View file

@ -8,7 +8,8 @@ EXECUTABLE=ambed
all: $(SOURCES) $(EXECUTABLE)
$(EXECUTABLE): $(OBJECTS)
$(CC) $(LDFLAGS) $(OBJECTS) -lftd2xx -Wl,-rpath,/usr/local/lib -o $@
$(CC) $(LDFLAGS) $(OBJECTS) -lftd2xx -Wl,-rpath,/usr/local/lib -lsystemd -o $@
.cpp.o:
$(CC) $(CFLAGS) $< -o $@

View file

@ -109,6 +109,18 @@ class xReflector {
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;
}
}
}
}

View file

@ -1,9 +1,10 @@
[Unit]
Description=AMBE Transcoder Daemon
After=network.target
Requires=network-online.target
[Service]
Type=simple
Type=notify
User=root
Group=root
ExecStartPre=-/sbin/rmmod ftdi_sio

5
scripts/ambedwatchdog Normal file
View file

@ -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

View file

@ -0,0 +1,7 @@
[Unit]
Description=Check ambedwatchdog
After=network.target
[Service]
Type=simple
ExecStart=/usr/bin/ambedwatchdog

View file

@ -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

3
scripts/xlxapi-update Executable file
View file

@ -0,0 +1,3 @@
#!/bin/bash
/usr/bin/wget -q -O- http://localhost/index.php?callhome=1 > /dev/null

View file

@ -0,0 +1,9 @@
[Unit]
Description=XLX API Service
After=network.target
[Service]
Type=simple
ExecStart=/usr/bin/xlxapi-update

View file

@ -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

16
scripts/xlxd.service Normal file
View file

@ -0,0 +1,16 @@
[Unit]
Description=XLX Reflector (XLX999)
After=network.target ambed.service
Requires=network-online.target
[Service]
Type=notify
User=xlxd
Group=xlxd
AmbientCapabilities=CAP_NET_RAW
ExecStart=/xlxd/xlxd XLX999 1.2.3.4 127.0.0.1
Restart=on-abnormal
RestartSec=30
[Install]
WantedBy=multi-user.target

View file

@ -31,6 +31,7 @@
#include "ctranscoder.h"
#include "cysfnodedirfile.h"
#include "cysfnodedirhttp.h"
#include <systemd/sd-daemon.h>
////////////////////////////////////////////////////////////////////////////////////////
// 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
{

View file

@ -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