-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathrun.sh
More file actions
executable file
·52 lines (43 loc) · 1.46 KB
/
run.sh
File metadata and controls
executable file
·52 lines (43 loc) · 1.46 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#!/bin/bash
# ProWaveDAQ Smart Startup Script
#
# Usage:
# ./run.sh # Default: Port 8080
# ./run.sh 3000 # Specify Port 3000
# ./run.sh 9000 # Specify Port 9000
# 1. Connect OVPN
echo "Connecting OVPN..."
./connection.sh
# 2. Set USB Latency
if [ -e /sys/bus/usb-serial/devices/ttyUSB0/latency_timer ]; then
sudo bash -c "echo 1 > /sys/bus/usb-serial/devices/ttyUSB0/latency_timer"
else
# Here only display warning but not stop, convenient to test in environment without device
echo "Warning: ttyUSB0 not detected, skip Latency setting."
fi
# 3. Parameter processing
PORT=${1:-8080}
# Validate Port
if ! [[ "$PORT" =~ ^[0-9]+$ ]] || [ "$PORT" -lt 1 ] || [ "$PORT" -gt 65535 ]; then
echo "Error: Invalid port number '$PORT'"
exit 1
fi
# 4. Prepare environment
source venv/bin/activate
clear
echo "============================================================"
echo "ProWaveDAQ System Launcher"
echo "============================================================"
echo "Web Interface : http://0.0.0.0:${PORT}/"
echo "Log File : logs/loguru.log (managed by loguru)"
echo "Log Rotation : 10 MB, retention 7 days"
echo "============================================================"
echo ""
# 5. Execute main program
# Note: Logging is handled by loguru in main.py
# - Console output: stdout/stderr
# - File output: logs/loguru.log (auto-rotated)
python src/main.py --port ${PORT}
# 6. Disconnect OVPN
./connection.sh --disconnect
echo "Bye"