Add service status and global manager from webapp
This commit is contained in:
parent
e44b8542b0
commit
d56f3806fa
|
@ -7,3 +7,5 @@ var/
|
|||
species_list.txt
|
||||
|
||||
push.sh
|
||||
|
||||
config/analyzer.conf
|
|
@ -0,0 +1,23 @@
|
|||
# Configuration file for BirdNET Analyzer
|
||||
|
||||
# Coordinates of the recorder
|
||||
LATITUDE="47.87842"
|
||||
LONGITUDE="0.21826"
|
||||
# Species selection list
|
||||
SPECIES_LIST="./config/species_list.txt"
|
||||
# Minimal confidence threshold
|
||||
CONFIDENCE=0.1
|
||||
# Recording duration (in seconds)
|
||||
RECORDING_DURATION=15
|
||||
RECORDING_AMPLIFICATION=1.5
|
||||
# Chunk folder location
|
||||
CHUNK_FOLDER="./var/chunks"
|
||||
# Audio recording device (pulseaudio)
|
||||
AUDIO_DEVICE="default"
|
||||
# Virtual env for BirdNET AI with required packages
|
||||
PYTHON_VENV="./.venv/birdnet-stream"
|
||||
# Database location
|
||||
DATABASE="./var/db.sqlite"
|
||||
|
||||
DAEMON_USER="birdnet"
|
||||
DAEMON_PASSWORD="secret"
|
|
@ -0,0 +1,52 @@
|
|||
#! /usr/bin/env bash
|
||||
|
||||
set -e
|
||||
# set -x
|
||||
|
||||
config_filepath="./config/analyzer.conf"
|
||||
|
||||
if [ -f "$config_filepath" ]; then
|
||||
source "$config_filepath"
|
||||
else
|
||||
echo "Config file not found: $config_filepath"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [[ -z $DAEMON_USER ]]
|
||||
then
|
||||
echo "DAEMON_USER is not set"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [[ -z $DAEMON_PASSWORD ]]
|
||||
then
|
||||
echo "DAEMON_PASSWORD is not set"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
SERVICES="$(sudo -S <<< $DAEMON_PASSWORD ls /etc/systemd/system/ | grep 'birdnet')"
|
||||
|
||||
DEBUG=${DEBUG:-0}
|
||||
|
||||
debug() {
|
||||
if [ $DEBUG -eq 1 ]; then
|
||||
echo "$1"
|
||||
fi
|
||||
}
|
||||
|
||||
manage() {
|
||||
action=$1
|
||||
debug "$action birdnet services"
|
||||
sudo -S <<< $DAEMON_PASSWORD systemctl $action $SERVICES
|
||||
echo "done"
|
||||
}
|
||||
|
||||
stop() {
|
||||
manage stop
|
||||
}
|
||||
|
||||
start() {
|
||||
manage start
|
||||
}
|
||||
|
||||
manage $1
|
|
@ -8,14 +8,22 @@
|
|||
position: relative;
|
||||
}
|
||||
|
||||
.column {
|
||||
.container.col {
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
.row {
|
||||
.container.row {
|
||||
flex-direction: row;
|
||||
}
|
||||
|
||||
.grid {
|
||||
display: grid;
|
||||
}
|
||||
|
||||
.grid > * {
|
||||
padding-left: 0.1em;
|
||||
}
|
||||
|
||||
.behind {
|
||||
position: relative;
|
||||
z-index: -1;
|
||||
|
@ -102,40 +110,36 @@ canvas {
|
|||
width: 100%;
|
||||
}
|
||||
|
||||
#statuses {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
#statuses li {
|
||||
list-style: none;
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
justify-content: space-between;
|
||||
|
||||
}
|
||||
|
||||
.status .bullet {
|
||||
#statuses .grid {
|
||||
display: grid;
|
||||
grid-template-rows: 1fr 1fr 1fr;
|
||||
grid-template-columns: 1fr 1fr 1fr;
|
||||
|
||||
gap: 0.1em;
|
||||
}
|
||||
|
||||
.status.bullet {
|
||||
border-radius: 50%;
|
||||
background-color: #999;
|
||||
width: 1em;
|
||||
height: 1em;
|
||||
display: inline-block;
|
||||
position: relative;
|
||||
top: 0.15em;
|
||||
margin-right: 0.5em;
|
||||
margin-left: 0.5em;
|
||||
top: 0.4em;
|
||||
}
|
||||
|
||||
.status.active .bullet {
|
||||
.status.active.bullet {
|
||||
background-color: #090;
|
||||
}
|
||||
|
||||
.status.inactive .bullet {
|
||||
.status.inactive.bullet {
|
||||
background-color: #900;
|
||||
}
|
||||
|
||||
|
||||
@media screen and (max-width: 700px) {
|
||||
main {
|
||||
padding: 1em;
|
||||
|
|
|
@ -66,7 +66,7 @@ class ServicesController extends AbstractController
|
|||
|
||||
private function systemd_service_status($service)
|
||||
{
|
||||
$command = "systemctl is-active ".$service;
|
||||
$command = "systemctl is-active birdnet_".$service.".service";
|
||||
$result = shell_exec($command);
|
||||
return $result;
|
||||
}
|
||||
|
|
|
@ -18,18 +18,17 @@
|
|||
</head>
|
||||
<body>
|
||||
{% block body %}
|
||||
<div class="above">
|
||||
{% include "menu.html.twig" %}
|
||||
</div>
|
||||
<div class="behind">
|
||||
<header></header>
|
||||
<main>
|
||||
{% block content %}
|
||||
<p>Welcome to BirdNET-stream !</p>
|
||||
{% endblock %}
|
||||
</main>
|
||||
{% include "footer.html.twig" %}
|
||||
</div>
|
||||
{% include "menu.html.twig" %}
|
||||
<header>
|
||||
<img class="logo" src="/media/logo.svg" alt="BirdNET logo">
|
||||
<h1>BirdNET-stream</h1>
|
||||
</header>
|
||||
<main>
|
||||
{% block content %}
|
||||
<p>Welcome to BirdNET-stream !</p>
|
||||
{% endblock %}
|
||||
</main>
|
||||
{% include "footer.html.twig" %}
|
||||
{% endblock %}
|
||||
</body>
|
||||
</html>
|
||||
|
|
|
@ -5,11 +5,12 @@
|
|||
{{ "Services status" | trans }}
|
||||
</h2>
|
||||
{% if status is defined and status | length > 0 %}
|
||||
<ul id="statuses">
|
||||
<ul id="statuses" class="container column">
|
||||
{% for service in status %}
|
||||
<li>
|
||||
<span class="name">{{ service["name"] }}</span>
|
||||
<span class="status"><span class="bullet {{ service["status"] }}"></span>{{ service["status"] }}</span>
|
||||
<li class="grid">
|
||||
<div class="col status bullet {{ service["status"] }}"></div>
|
||||
<div class="col name">{{ service["name"] }}</div>
|
||||
<div class="col status">{{ service["status"] }}</div>
|
||||
</li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
|
|
Loading…
Reference in New Issue