added service for linux

This commit is contained in:
= 2024-08-17 17:13:02 -04:00
parent f4a8e05b90
commit 2ebfc20537
4 changed files with 31 additions and 2 deletions

1
.gitignore vendored
View File

@ -1 +1,2 @@
*.pyc
fwledmonitor.service

21
install_as_service.sh Normal file
View File

@ -0,0 +1,21 @@
chmod +x run.sh
rm -f fwledmonitor.service || true
cat <<EOF >>./fwledmonitor.service
[Unit]
Description=Framework 16 LED System Monitor
After=network.service
[Service]
Type=simple
Restart=always
WorkingDirectory=$PWD
ExecStart=sh -c "'$PWD/run.sh'"
[Install]
WantedBy=default.target
EOF
sudo systemctl stop fwledmonitor
sudo cp fwledmonitor.service /lib/systemd/system
sudo systemctl daemon-reload
sudo systemctl enable fwledmonitor

View File

@ -78,9 +78,13 @@ if __name__ == "__main__":
draw_bar(grid, last_network_download, foreground_value, bar_x_offset=5, draw_at_bottom=True) # Download
draw_borders_right(grid, background_value)
right_drawing_queue.put(grid)
except KeyboardInterrupt:
break
except Exception as e:
import traceback
print(f"Error in main loop: {e}")
traceback.print_exc()
time.sleep(1.0)
time.sleep(0.1)
print("Exiting")

3
run.sh Normal file
View File

@ -0,0 +1,3 @@
sudo apt install python3-numpy python3-psutil
python3 ./led_system_monitor.py