Skip to content
Open
2 changes: 2 additions & 0 deletions ambed/cambeserver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
#include "ccontroller.h"
#include "cvocodecs.h"
#include "cambeserver.h"
#include <systemd/sd-daemon.h>

////////////////////////////////////////////////////////////////////////////////////////

Expand Down Expand Up @@ -81,6 +82,7 @@ bool CAmbeServer::Start(void)
{
//
m_pThread = new std::thread(CAmbeServer::Thread, this);
sd_notify(0, "READY=1");
}

// done
Expand Down
3 changes: 3 additions & 0 deletions ambed/cvocodecs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
#include "main.h"
#include <string.h>
#include "cvocodecs.h"
#include <systemd/sd-daemon.h>

////////////////////////////////////////////////////////////////////////////////////////
// global object
Expand Down Expand Up @@ -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;
Expand Down
3 changes: 2 additions & 1 deletion ambed/makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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 $@
Expand Down
12 changes: 12 additions & 0 deletions dashboard/pgs/class.reflector.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
}
}

Expand Down
3 changes: 2 additions & 1 deletion scripts/ambed.service
Original file line number Diff line number Diff line change
@@ -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
Expand Down
5 changes: 5 additions & 0 deletions scripts/ambedwatchdog
Original file line number Diff line number Diff line change
@@ -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
7 changes: 7 additions & 0 deletions scripts/ambedwatchdog.service
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
[Unit]
Description=Check ambedwatchdog
After=network.target

[Service]
Type=simple
ExecStart=/usr/bin/ambedwatchdog
10 changes: 10 additions & 0 deletions scripts/ambedwatchdog.timer
Original file line number Diff line number Diff line change
@@ -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 changes: 3 additions & 0 deletions scripts/xlxapi-update
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/bash
/usr/bin/wget -q -O- http://localhost/index.php?callhome=1 > /dev/null

9 changes: 9 additions & 0 deletions scripts/xlxapi-update.service
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
[Unit]
Description=XLX API Service
After=network.target

[Service]
Type=simple
ExecStart=/usr/bin/xlxapi-update


9 changes: 9 additions & 0 deletions scripts/xlxapi-update.timer
Original file line number Diff line number Diff line change
@@ -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 changes: 16 additions & 0 deletions scripts/xlxd.service
Original file line number Diff line number Diff line change
@@ -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
2 changes: 2 additions & 0 deletions src/creflector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
#include "ctranscoder.h"
#include "cysfnodedirfile.h"
#include "cysfnodedirhttp.h"
#include <systemd/sd-daemon.h>

////////////////////////////////////////////////////////////////////////////////////////
// constructor
Expand Down Expand Up @@ -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
{
Expand Down
2 changes: 1 addition & 1 deletion src/makefile
Original file line number Diff line number Diff line change
@@ -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
Expand Down