update
This commit is contained in:
@@ -56,8 +56,8 @@
|
||||
<div class="col-lg-6 col-12">
|
||||
<div class="card" style="height: 80vh;">
|
||||
<div class="card-header">
|
||||
Master logs
|
||||
<button type="submit" class="btn btn-secondary btn-sm" id="refresh-master-log">Refresh</button>
|
||||
SARA logs
|
||||
<button type="submit" class="btn btn-secondary btn-sm" id="refresh-sara-log">Refresh</button>
|
||||
<button type="submit" class="btn btn-secondary btn-sm" onclick="clear_loopLogs()">Clear</button>
|
||||
<span id="script_running"></span>
|
||||
</div>
|
||||
@@ -114,15 +114,15 @@
|
||||
const loop_card_content = document.getElementById('card_loop_content');
|
||||
const boot_card_content = document.getElementById('card_boot_content');
|
||||
|
||||
//Getting Master logs
|
||||
console.log("Getting master logs");
|
||||
displayLogFile('../logs/master.log', loop_card_content);
|
||||
//Getting Sara logs
|
||||
console.log("Getting sara logs");
|
||||
displayLogFile('../logs/sara_service.log', loop_card_content, true, 1000);
|
||||
|
||||
console.log("Getting app/boot logs");
|
||||
displayLogFile('../logs/app.log', boot_card_content);
|
||||
displayLogFile('../logs/app.log', boot_card_content, true, 1000);
|
||||
|
||||
// Setup master log with refresh button
|
||||
setupLogRefreshButton('refresh-master-log', '../logs/master.log', 'card_loop_content', 3000);
|
||||
// Setup Sara log with refresh button
|
||||
setupLogRefreshButton('refresh-sara-log', '../logs/sara_service.log', 'card_loop_content', 3000);
|
||||
|
||||
// Setup boot log with refresh button
|
||||
setupLogRefreshButton('refresh-boot-log', '../logs/app.log', 'card_boot_content', 300);
|
||||
|
||||
@@ -14,7 +14,7 @@ g++ -I /var/www/moduleair_pro_4g/matrix/include -L /var/www/moduleair_pro_4g/mat
|
||||
|
||||
|
||||
Pour lancer:
|
||||
sudo /var/www/moduleair_pro_4g/matrix/welcome_screen
|
||||
sudo /var/www/moduleair_pro_4g/matrix/welcomeScreen/welcome_screen
|
||||
|
||||
*/
|
||||
|
||||
|
||||
0
master.py → old/master.py
Executable file → Normal file
0
master.py → old/master.py
Executable file → Normal file
0
run_every_10_seconds.sh → old/run_every_10_seconds.sh
Executable file → Normal file
0
run_every_10_seconds.sh → old/run_every_10_seconds.sh
Executable file → Normal file
228
services/setup_services.sh
Normal file
228
services/setup_services.sh
Normal file
@@ -0,0 +1,228 @@
|
||||
#!/bin/bash
|
||||
# File: /var/www/moduleair_pro_4g/services/setup_services.sh
|
||||
# Purpose: Set up all systemd services for moduleair data collection
|
||||
# to install:
|
||||
# sudo chmod +x /var/www/moduleair_pro_4g/services/setup_services.sh
|
||||
# sudo /var/www/moduleair_pro_4g/services/setup_services.sh
|
||||
|
||||
echo "Setting up moduleair systemd services and timers..."
|
||||
|
||||
# Create directory for logs if it doesn't exist
|
||||
mkdir -p /var/www/moduleair_pro_4g/logs
|
||||
|
||||
# Create service and timer files for NPM Data
|
||||
cat > /etc/systemd/system/moduleair-npm-data.service << 'EOL'
|
||||
[Unit]
|
||||
Description=moduleair NPM Data Collection Service
|
||||
After=network.target
|
||||
|
||||
[Service]
|
||||
Type=oneshot
|
||||
ExecStart=/usr/bin/python3 /var/www/moduleair_pro_4g/NPM/get_data_modbus_v3.py
|
||||
User=root
|
||||
WorkingDirectory=/var/www/moduleair_pro_4g
|
||||
StandardOutput=append:/var/www/moduleair_pro_4g/logs/npm_service.log
|
||||
StandardError=append:/var/www/moduleair_pro_4g/logs/npm_service_errors.log
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
EOL
|
||||
|
||||
cat > /etc/systemd/system/moduleair-npm-data.timer << 'EOL'
|
||||
[Unit]
|
||||
Description=Run moduleair NPM Data Collection every 10 seconds
|
||||
Requires=moduleair-npm-data.service
|
||||
|
||||
[Timer]
|
||||
OnBootSec=10s
|
||||
OnUnitActiveSec=10s
|
||||
AccuracySec=1s
|
||||
|
||||
[Install]
|
||||
WantedBy=timers.target
|
||||
EOL
|
||||
|
||||
# Create service and timer files for CO2 Data
|
||||
cat > /etc/systemd/system/moduleair-co2-data.service << 'EOL'
|
||||
[Unit]
|
||||
Description=moduleair co2 Data Collection Service
|
||||
After=network.target
|
||||
|
||||
[Service]
|
||||
Type=oneshot
|
||||
ExecStart=/usr/bin/python3 /var/www/moduleair_pro_4g/MH-Z19/write_data.py
|
||||
User=root
|
||||
WorkingDirectory=/var/www/moduleair_pro_4g
|
||||
StandardOutput=append:/var/www/moduleair_pro_4g/logs/co2_service.log
|
||||
StandardError=append:/var/www/moduleair_pro_4g/logs/co2_service_errors.log
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
EOL
|
||||
|
||||
cat > /etc/systemd/system/moduleair-co2-data.timer << 'EOL'
|
||||
[Unit]
|
||||
Description=Run moduleair co2 Data Collection every 10 seconds
|
||||
Requires=moduleair-co2-data.service
|
||||
|
||||
[Timer]
|
||||
OnBootSec=10s
|
||||
OnUnitActiveSec=10s
|
||||
AccuracySec=1s
|
||||
|
||||
[Install]
|
||||
WantedBy=timers.target
|
||||
EOL
|
||||
|
||||
# Create service and timer files for Envea Data
|
||||
cat > /etc/systemd/system/moduleair-envea-data.service << 'EOL'
|
||||
[Unit]
|
||||
Description=moduleair Envea Data Collection Service
|
||||
After=network.target
|
||||
|
||||
[Service]
|
||||
Type=oneshot
|
||||
ExecStart=/usr/bin/python3 /var/www/moduleair_pro_4g/envea/read_value_v2.py
|
||||
User=root
|
||||
WorkingDirectory=/var/www/moduleair_pro_4g
|
||||
StandardOutput=append:/var/www/moduleair_pro_4g/logs/envea_service.log
|
||||
StandardError=append:/var/www/moduleair_pro_4g/logs/envea_service_errors.log
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
EOL
|
||||
|
||||
cat > /etc/systemd/system/moduleair-envea-data.timer << 'EOL'
|
||||
[Unit]
|
||||
Description=Run moduleair Envea Data Collection every 10 seconds
|
||||
Requires=moduleair-envea-data.service
|
||||
|
||||
[Timer]
|
||||
OnBootSec=10s
|
||||
OnUnitActiveSec=10s
|
||||
AccuracySec=1s
|
||||
|
||||
[Install]
|
||||
WantedBy=timers.target
|
||||
EOL
|
||||
|
||||
# Create service and timer files for SARA Data (No Lock File Needed)
|
||||
cat > /etc/systemd/system/moduleair-sara-data.service << 'EOL'
|
||||
[Unit]
|
||||
Description=moduleair SARA Data Transmission Service
|
||||
After=network.target
|
||||
|
||||
[Service]
|
||||
Type=oneshot
|
||||
ExecStart=/usr/bin/python3 /var/www/moduleair_pro_4g/loop/SARA_send_data_v2.py
|
||||
User=root
|
||||
WorkingDirectory=/var/www/moduleair_pro_4g
|
||||
StandardOutput=append:/var/www/moduleair_pro_4g/logs/sara_service.log
|
||||
StandardError=append:/var/www/moduleair_pro_4g/logs/sara_service_errors.log
|
||||
RuntimeMaxSec=200s
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
EOL
|
||||
|
||||
cat > /etc/systemd/system/moduleair-sara-data.timer << 'EOL'
|
||||
[Unit]
|
||||
Description=Run moduleair SARA Data Transmission every 60 seconds
|
||||
Requires=moduleair-sara-data.service
|
||||
|
||||
[Timer]
|
||||
OnBootSec=60s
|
||||
OnUnitActiveSec=60s
|
||||
AccuracySec=1s
|
||||
# This is the key setting that prevents overlap
|
||||
Persistent=true
|
||||
|
||||
[Install]
|
||||
WantedBy=timers.target
|
||||
EOL
|
||||
|
||||
# Create service and timer files for BME280 Data
|
||||
cat > /etc/systemd/system/moduleair-bme280-data.service << 'EOL'
|
||||
[Unit]
|
||||
Description=moduleair BME280 Data Collection Service
|
||||
After=network.target
|
||||
|
||||
[Service]
|
||||
Type=oneshot
|
||||
ExecStart=/usr/bin/python3 /var/www/moduleair_pro_4g/BME280/get_data_v2.py
|
||||
User=root
|
||||
WorkingDirectory=/var/www/moduleair_pro_4g
|
||||
StandardOutput=append:/var/www/moduleair_pro_4g/logs/bme280_service.log
|
||||
StandardError=append:/var/www/moduleair_pro_4g/logs/bme280_service_errors.log
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
EOL
|
||||
|
||||
cat > /etc/systemd/system/moduleair-bme280-data.timer << 'EOL'
|
||||
[Unit]
|
||||
Description=Run moduleair BME280 Data Collection every 120 seconds
|
||||
Requires=moduleair-bme280-data.service
|
||||
|
||||
[Timer]
|
||||
OnBootSec=120s
|
||||
OnUnitActiveSec=120s
|
||||
AccuracySec=1s
|
||||
|
||||
[Install]
|
||||
WantedBy=timers.target
|
||||
EOL
|
||||
|
||||
# Create service and timer files for Database Cleanup
|
||||
cat > /etc/systemd/system/moduleair-db-cleanup-data.service << 'EOL'
|
||||
[Unit]
|
||||
Description=moduleair Database Cleanup Service
|
||||
After=network.target
|
||||
|
||||
[Service]
|
||||
Type=oneshot
|
||||
ExecStart=/usr/bin/python3 /var/www/moduleair_pro_4g/sqlite/flush_old_data.py
|
||||
User=root
|
||||
WorkingDirectory=/var/www/moduleair_pro_4g
|
||||
StandardOutput=append:/var/www/moduleair_pro_4g/logs/db_cleanup_service.log
|
||||
StandardError=append:/var/www/moduleair_pro_4g/logs/db_cleanup_service_errors.log
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
EOL
|
||||
|
||||
cat > /etc/systemd/system/moduleair-db-cleanup-data.timer << 'EOL'
|
||||
[Unit]
|
||||
Description=Run moduleair Database Cleanup daily
|
||||
Requires=moduleair-db-cleanup-data.service
|
||||
|
||||
[Timer]
|
||||
OnBootSec=1h
|
||||
OnUnitActiveSec=24h
|
||||
AccuracySec=1h
|
||||
|
||||
[Install]
|
||||
WantedBy=timers.target
|
||||
EOL
|
||||
|
||||
# Reload systemd to recognize new services
|
||||
systemctl daemon-reload
|
||||
|
||||
# Enable and start all timers
|
||||
echo "Enabling and starting all services..."
|
||||
for service in npm envea sara bme280 co2 db-cleanup; do
|
||||
systemctl enable moduleair-$service-data.timer
|
||||
systemctl start moduleair-$service-data.timer
|
||||
echo "Started moduleair-$service-data timer"
|
||||
done
|
||||
|
||||
echo "Checking status of all timers..."
|
||||
systemctl list-timers | grep moduleair
|
||||
|
||||
echo "Setup complete. All moduleair services are now running."
|
||||
echo "To check the status of a specific service:"
|
||||
echo " sudo systemctl status moduleair-npm-data.service"
|
||||
echo "To view logs for a specific service:"
|
||||
echo " sudo journalctl -u moduleair-npm-data.service"
|
||||
echo "To restart a specific timer:"
|
||||
echo " sudo systemctl restart moduleair-npm-data.timer"
|
||||
Reference in New Issue
Block a user